Hi,
On 27 March 2013 15:50, Sayan Chatterjee <sayanchatter...@gmail.com> wrote: > Dear all, > > When trying to print or assign array elements, getting the following error: > > Traceback (most recent call last): > File "ZA.py", line 32, in <module> > p_za[i] = p_initial[i] + t*K*cos(K*p_initial[i]); > IndexError: index out of bounds > > I am using Numpy, is it due to that? I am attaching the code herewith. > Not Numpy no. The p_za list appears to be empty at the point where the above assgnment to p_za[i] is done, hence you get the "IndexError" message. You should initialise p_za to be as long as needed first. Maybe by simply using p_za = [None] * N instead of assigning [], or alternately perhaps by appending instead at the point where you first reference p_ze[i]. Walter
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor