Quoting Vincent Wan <[EMAIL PROTECTED]>: > 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.
List comprehension will do it: >>> stuff = [ [ 0, "sdfsd", "wrtew"], [1, "rht", "erterg" ] ] >>> [x[0] for x in stuff] [0, 1] stuff[:] is just a shallow copy of stuff. So stuff[:][0] is exactly the same as stuff[0]. >>> stuff[:][0] is stuff[0] True -- John. _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
