[Tutor] IndexError: index out of bounds

Joel Goldstick joel.goldstick at gmail.com
Wed Mar 27 17:04:04 CET 2013


On Wed, Mar 27, 2013 at 11:50 AM, Sayan Chatterjee <
sayanchatterjee at 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]);
>

You declare p_za = [] above.  So there is no p_za[i].  You should use
append since you are adding elements to the end of the list.

> IndexError: index out of bounds
>
> I am using Numpy, is it due to that? I am attaching the code herewith.
>
>
>
> --
>
>
> --------------------------------------------------------------------------
> *Sayan  Chatterjee*
> Dept. of Physics and Meteorology
> IIT Kharagpur
> Lal Bahadur Shastry Hall of Residence
> Room AB 205
> Mob: +91 9874513565
> blog: www.blissprofound.blogspot.com
>
> Volunteer , Padakshep
> www.padakshep.org
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130327/9364fdf8/attachment.html>


More information about the Tutor mailing list