list of lists
__peter__ at web.de
Mon Sep 15 16:58:46 CEST 2003
> I have a list that consists of lists.
> E.g. T=[[1, 2, 3], [4, 5], ]
> Is there a way to address the a specific component in the "inner" list
> 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
> print a
> 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
Your example rather than your problem specification suggests that you want
them all. If I'm guessing right:
for lst in lol:
for item in lst:
T=[[1, 2, 3], [4, 5], ]
for item in flatten(T):
Indices seem to be a dying breed :-)
More information about the Python-list