title: compare current item to next item in a python list
body: <p>Considering a python list, how can I compare current item to next it ? for example:</p>
  
  <pre><code>mylist = [1, 2, 2, 4, 2, 3]
  for i in mylist:        
      if i == next item:
         replace (both i and next item) with "same value"
  
   &gt;&gt;&gt; [1, "same value", "same value", 4, 2, 3]  
  </code></pre>