How can I find the position in a list where an item differs from the previous item?
<pre><code>l1 = [1,2,2,2]
</code></pre>

<p>In the list above, I know that the element differs in l1[0]. Is there any way to find the position in python?</p>

<pre><code>import numpy as np
UniqueList, indices = np.unique(l1, return_inverse=True)
print(UniqueList) #Unique elements in List l1
</code></pre>

<p>array([1, 2])</p>

<pre><code>print(indices)  #indices of element in l1 mapped to UniqueList
</code></pre>

<p>array([0, 1, 1, 1])</p>

python