title: Python - How to check if the next value in a list is the same as the previous?
body: <p>Let's say we have this array:</p>
  <p><code>arr2 = [2, 3, 1, 2, 2]</code></p>
  <p>I've tried the following:</p>
  <pre><code>for i,x in enumerate(arr2):
   
      if x == 2 and x[i+1] == 2:
   
          print('TwosPair')
  </code></pre>
  <p>But receiving the following error:</p>
  <p><strong>TypeError: 'int' object is not subscriptable</strong></p>
  <p>Shouldn't I be able to check the previous index / next one, using enumerate?</p>
  <p>I also tried the following:</p>
  <pre><code>for i,x in enumerate(arr2):
  
      if x == 2 and x[arr2.index(i)+1] == 2:
   
          print('TwosPair')
  </code></pre>
  <p>But getting this error now:</p>
  <p><strong>ValueError: 0 is not in list</strong></p>
  <p>What 0 is it talking about?</p>