list of lists
Paul Osman
posman at eval.ca
Mon Sep 15 10:16:17 EDT 2003
On Mon, 15 Sep 2003, Tom wrote:
> Hi,
>
> I have a list that consists of lists.
> E.g. T=[[1, 2, 3], [4, 5], [6]]
> Is there a way to address the a specific component in the "inner" list
> directly?
> E.g. right now I want to get the second value of the first list.
> Unfortunately I have to save it to a variable first and then read it.
> a = T[0]
> print a[1]
>
> That kind of sucks, becaus I have to read a lot of values from a lot of
> lists! :-(
> Is there a faster way than my saving it to a "help variable" first?
>
> Thanks folks!!
>
> Regards, Tom
>
>
Hi Tom,
Do you mean this?
>>> T=[[1, 2, 3], [4, 5], [6]]
>>> T[0][1]
2
>>> print T[0][1]
2
>>> print T[1][1]
5
HTH,
--
Paul Osman
paul at eval.ca
http://perl.eval.ca
"Idealists...foolish enough to throw caution
to the winds...have advanced mankind and have
enriched the world."
- Emma Goldman
More information about the Python-list
mailing list