[Tutor] I want some help with arrays...

James Matthews jamesmatt18 at gmail.com
Fri May 18 05:40:48 CEST 2007


Also computer start counting from 0 you can change this when you learn the 
language more but it isn't recommended!

http://www.goldwatches.com/watches.asp?Brand=39
----- Original Message ----- 
From: "Luke Paireepinart" <rabidpoobear at gmail.com>
To: "Alan Gilfoy" <agilfoy at frontiernet.net>
Cc: <tutor at python.org>
Sent: Thursday, May 17, 2007 9:46 PM
Subject: Re: [Tutor] I want some help with arrays...


> 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
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor 



More information about the Tutor mailing list