Novice Question: two lists -> dictionary
Alex
alex at somewhere.round.here
Thu Apr 15 12:11:04 EDT 1999
You could do something like
**************************************************
ListA = ['10', '10', '20', '20', '20', '24']
ListB = ['23', '44', '11', '19', '57', '3']
Dict = {}
for (key, value) in map (None, ListA, ListB):
Dict [key] = Dict.get (key, [])
Dict [key].append (value)
print Dict
**************************************************
The result is
{'24': ['3'], '10': ['23', '44'], '20': ['11', '19', '57']}
See you.
Alex.
More information about the Python-list
mailing list