[Tutor] I want some help with arrays...
Luke Paireepinart
rabidpoobear at gmail.com
Fri May 18 03:46:10 CEST 2007
Alan Gilfoy wrote:
> Why Python starts counting at [0] instead of at [1] is a whole other issue. :D
>
> array = [["0.0", "0.1"], ["1.0", "1.1"]]
>
> array[0[1]] seems right, although it isn't, because the index (0) and
> the subindex(1) are nested in 'array[0[1]]' much like the list and
> sublist that I'm "calling" from with the indexes.
>
> array[0][1] works instead? Gotcha.
>
Think of this command as being interpreted from left to right.
command: array[0[1]]
array[ ... now what do we index?
0[1] -> this doesn't work, it raises an error.
Whereas this:
command: array[0][1]
array[ ... what do we index?
0 ] -> we index the first item.
so now we have this:
command: ["0.0","0.1"][1]
["0.0","0.1"] [ ... what do we index?
1 ] -> we index the 2nd item.
so now we have this:
"0.1"
there are no more commands, so we stop here.
Hope that made sense,
-Luke
More information about the Tutor
mailing list