Combine two dictionaries into a list of 3-tuples

Scott David Daniels Scott.Daniels at Acm.Org
Wed Nov 10 16:25:31 EST 2004


Nickolay Kolev wrote:
> My attempts so far:
> ... [(t, c, l) for t, c in one.items() for (t, l) in two.items()]

Simply forget about items for two.
     [(key, val1, two[key]) for key, val1 in one.items() if key in two]

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list