title: Python 'list out of index error'
body: <p>I had written a code to read data from file for interpolation but when i run the program is saying list out of index error at "pointsx.append(float(words[0])):</p>
  
  <pre><code>with open("points.dat","r") as f:
       data = f.readlines()
       pointsx = []
       pointsy = []
       for line in data:
              words=(line.split())
              pointsx.append(float(words[0]))
              pointsy.append(float(words[1]))
  
  x = float(input('Enter the  value of X:\n'))
  
  i=0
  lenx=len(pointsx)
  
  if x&lt;pointsx[0]:\n
          print("this Particular value of X is lower than the range of interpolation \n")
  elif x&gt;pointsx[lenx-1]:
          print("This particular value of x is higher than the range of interpolation\n")
  else:
          for i in range(lenx-1):
                  if(x&lt;=pointsx[i]):
                           break;
  
  
                  y=pointsy[i-1]+((pointsy[i]-pointsy[i-1])/(pointsx[i]-pointsx[i-1]))*(x-pointsx[i-1])
                  print("The required value of y is ",y,"\n")
  
  
  f.close()
  </code></pre>