Q:

Python, the same "for" for two lists

I have two lists
a: a, b, c, d, e
b: blue, white, brown, yellow, red

I need a to become blue's key in a dictonary, so i need to do this:
dictonary[a]="blue"

but how do I do it using the same for...

A:

Use zip() to merge a and b:
dict(zip(a, b))

Because the dict() constructor also can take a sequence of (key, value) pairs no for loops are needed at all.

