IndexError: list index out of range


I am pretty new in Python (or more precisely in programming).

I found on the Internet (link) this code:

import numpy as np import scipy.integrate as sp import sys g, l, k = 9.81, 10, float( sys.argv[1] ) PTS = 3000 def rhs( y, t, g, l, k ): return [ k*t/l * np.cos(y[1]) - g/l * np.sin(y[1]), y[0] ] y0 = [ 0, 0 ] t = np.linspace( 0, 30, PTS+1 ) y = sp.odeint( rhs , y0, t, args = (g, l, k) ) for i in range(PTS): print( t[i], y[i][1] * 180/np.pi, np.arctan(k*t[i]/g) * 180/np.pi ) 

I understood that I need to input a value of k to this code, so I got this code:

import numpy as np import scipy.integrate as sp import sys g, l, k = 9.81, 10, 0.4, float( sys.argv[1] ) PTS = 3000 def rhs( y, t, g, l, k ): return [ k*t/l * np.cos(y[1]) - g/l * np.sin(y[1]), y[0] ] y0 = [ 0, 0 ] t = np.linspace( 0, 30, PTS+1 ) y = sp.odeint( rhs , y0, t, args = (g, l, k) ) for i in range(PTS): print( t[i], y[i][1] * 180/np.pi, np.arctan(k*t[i]/g) * 180/np.pi ) 

But I got an error: IndexError: list index out of range.

I found on the Internet that this error means that I am providing an index for which a list element does not exist, but I do not know, how to fix it. Could somebody explain to me where is the problem and alternatively how to fix it, please?