elegant python style for loops

Asun Friere afriere at yahoo.co.uk
Thu May 10 02:46:34 EDT 2007


On May 10, 4:20 pm, "Diez B. Roggisch" <d... at nospam.web.de> wrote:

> for a, b in zip(lista, listb):
>     ...

You don't even need the for loop nowadays.  Just pass the zipped list
to a dictionary constructor thusly:
newdict = dict(zip(listKeys,listValues))

Asun




More information about the Python-list mailing list