What you probably want is: [elem_list[2] for elem_list in List]
If you are not sure that the list have at least three elements, you can use something like this: [(elem_list + [None, None, None])[2] for elem_list in List] Which will use None as a default value. Andreas Am Dienstag, den 04.03.2008, 14:03 -0800 schrieb washakie: > Could someone please explain 'slices' also for dictionaries? > > basically, I'd like to know how you would call every 3rd element in a list > of lists... > > My logic says: ThirdElems=List[:][2] > > Which to me reads, for every item in List (which are lists), return the > third item. > but this doesn't work. > > Thanks!
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
