How to create a dict with letters as keys in a concise way?
dictionary, python
Solution
You can use `string.ascii_lowercase` and dict comprehension here.
In [4]: from string import ascii_lowercase as al
For Python 2.7+:
In [5]: dic = {x:i for i, x in enumerate(al, 1)}
For Python 2.6 or earlier:
In [7]: dic = dict((y, x) for x, y in enumerate(al, 1))
Problem
I created an dictionary of the 26 alphabet letters like this: ``` aDict={ "a": 1, "b": 2, "c": 3, "d": 4, etc... } ``` I'm trying make my code better and my question is, is there any shorter way to do this without typing all these numbers out?