Loop over list of pairs

Ulrich Petri ulope at gmx.de
Thu Jun 5 18:19:53 CEST 2003

"Thomas Güttler" <guettler at thomas-guettler.de> schrieb im Newsbeitrag
news:bbnjsu$bb260$1 at ID-63505.news.dfncis.de...
> Hi!
> What is the prefered way of loop over
> a list like this?
>  mylist=[1, "one", 2, "two", 3, "three"]

Better use dictionaries:

{1:'one', 2:'two', 3:'three'}

or lists of lists:

[[1,'one'], [2,'two'], [3,'three']]

Ciao Ulrich

More information about the Python-list mailing list