Vincent Wan wrote:

If I have a list stuff = [[0,sdfsd,wrtew], [1, rht,erterg]] whats the most concise way to print the first elements:

[0, 1]

if tried    print stuff[:][0]  but that just prints the whole list.

Vincent

------------------------------------------------------------------------ --------------
PhD Candidate
Committee on the Conceptual and Historical Studies of Science
University of Chicago


PO Box 73727
Fairbanks, AK 99707

wan AT walrus DOT us (change CAPS to @ and . )

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


>>> 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]

List comprehensions - cool stuff ;-)

--
Email: singingxduck AT gmail DOT com
AIM: singingxduck
Programming Python for the fun of it.

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

Reply via email to