can't assign value to array element
Dennis Lee Bieber
wlfraed at ix.netcom.com
Mon Nov 4 00:22:04 EST 2002
Joe Heafner fed this fish to the penguins on Sunday 03 November 2002
06:23 pm:
> m=10
>
> y = zeros(m, Float)
>
> for j in range(0,m,1):
> y[j+1] = y+(k1+2.*k2+2.k3+k4)/6.
> t[j+1] = a+h*(j+1)
>
> When run, this code give the error "TypeError: object does not support
> item assignment" for hte next to last line. I presume the last line
> would give the same error. I'm very new to Python and haven't been
> able to find documentation about htis specific problem, and I've been
> working (literally) all day on this. What am I doint wrong? I'd
> appreciate any help.
>
Uhmmm... Assuming zeros(m, Float) produces an array indexed from
0..(m-1), then won't the last iteration of the for loop generate y[10]
=... IE, out of range...
--
--
> ============================================================== <
> wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
> wulfraed at dm.net | Bestiaria Support Staff <
> ============================================================== <
> Bestiaria Home Page: http://www.beastie.dm.net/ <
> Home Page: http://www.dm.net/~wulfraed/ <
More information about the Python-list
mailing list