title: Calculate difference between adjacent items in a python list
body: <p>I have a list of millions of numbers.  I want to find out if the difference between each number in the ordered list is the same for the entire list.</p>
  
  <p>list_example = [ 0, 5, 10, 15, 20, 25, 30, 35, 40, ..etc etc etc]</p>
  
  <p>What's the best way to do this?</p>
  
  <p>My try:</p>
  
  <pre><code>import collections
  
  list_example = [ 0, 5, 10, 15, 20, 25, 30, 35, 40 ]
  
  count = collections.Counter()
  
  for x,y in zip(list_example[0::],list_example[1::]):
      print x,y,y-x
      count[y-x] +=1
  
  if len( count ) == 1:
      print 'Differences all the same'
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>0 5 5
  5 10 5
  10 15 5
  15 20 5
  20 25 5
  25 30 5
  30 35 5
  35 40 5
  Differences all the same
  </code></pre>