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...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With