title: Compare previous and next values when looping through a list in Python
body: <p>I should compare the previous, actual and next values in a list.
  This lines of code here underneath doesn't fully works.</p>
  <p>The results of the code are:</p>
  <pre><code>5 4 6
  8 10 11
  20 18 19
  </code></pre>
  <p>so I miss values like</p>
  <pre><code>9 8 10   
  </code></pre>
  <p>and values like</p>
  <pre><code>8 10 11
  </code></pre>
  <p>are simply wrong.</p>
  <p>What am I missing in the <code>enumerate</code> method?</p>
  <pre><code>list=[1,2,3,4,5,4,6,7,9,8,10,11,14,15,16,20,18,19]
  
  for i,n in enumerate (list):
  
      if (i + 1 &lt; len( list ) and i - 1 &gt;= 0):
  
          a = str( list[i - 1] )
          b = str( n )
          c = str( list[i + 1] )
  
          if a&gt;b&lt;c:
              print (a,b,c)
  </code></pre>