Is it possible to create a dictionary comprehension in Python (for the keys)?
Without list comprehensions, you can use something like this:
l = [] fo
I really like the @mgilson comment, since if you have a two iterables, one that corresponds to the keys and the other the values, you can also do the following.
keys = ['a', 'b', 'c'] values = [1, 2, 3] d = dict(zip(keys, values))
giving
d = {'a': 1, 'b': 2, 'c': 3}