[Tutor] (no subject)
Mark Rowe
mark21rowe@yahoo.com
Tue, 27 Nov 2001 18:00:42 -0800 (PST)
--- Pijus Virketis <virketis@fas.harvard.edu> wrote:
> Hi,
>
> I am not quite sure what you mean by
> "two-dimensional" list, so I'll just show
> what I would think of as a 2D list myself. Consider
> this:
>
> >>> L = [[1, 2, 3], [4, 5,6], [7, 8, 9]]
>
> This list of three list could be seen as a rough
> replication of the matrix:
>
> 1 2 3
> 4 5 6
> 7 8 9
>
> The list can be indexed somewhat like a matrix:
>
> >>> print L[1][2]
> 2
>
> We asked for the first row and second column, and
> got the right number. This
> could do the job for you.
[snip]
> Cheers,
>
> Pijus
>
That would actually return 6 in the example that you
used. This is because sequences are indexed starting
at zero. Therefore you were probably looking for:
>>> print L[0][1]
2
Mark Rowe
__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1