Two variable dictionary comprehension

Deborah Swanson python at deborahswanson.net
Sun Apr 2 21:26:07 EDT 2017


It seems like this should be easy to rewrite as a dict comprehension:

    records_idx = {}
    for idx, label in enumerate(records[0]):
        records_idx[label] = idx

Maybe I'm having another "dumb day", or maybe I've just been struggling
with this (larger) problem for too long, but eveything I try to get an
equivalent dict comprehension for the 3 lines above is not working.




More information about the Python-list mailing list