title: To check if a list of numbers is arithmetic or geometric with python
body: <p>Below is the code i have written which only check the 1st and the last patter and not in the middle. 
  Any help is much appreciated. </p>
  
  <pre><code>def arith_geo(list_n):
      if len(list_n) == 0:
          return 0
  
      for n in range(len(list_n) - 1): 
          if (list_n[n + 1] - list_n[n]) == (list_n[n-1] - list_n[n-2]):
              return 'Arithmetic'
          elif (list_n[n + 1] / list_n[n]) == (list_n[n -1 ] / list_n[n - 2]):
              return 'Geometric'
          else:
              return -1
  print(arith_geo([1, 2, 3, 8, 5, 6]))
  </code></pre>