On Wed, 12 Jan 2005, Orri Ganel wrote:

>  >>> stuff = [[0,'sdfsd','wrtew'], [1, 'rht','erterg']]
>  >>> stuff
> [[0, 'sdfsd', 'wrtew'], [1, 'rht', 'erterg']]
>  >>> print [stuff[i][0] for i in range(len(stuff))]
> [0, 1]


Hi Orri,

An alternative way to write this is:

###
print [row[0] for row in stuff]
###

which extracts the first element out of every "row" sublist in 'stuff'.


Best of wishes!

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to