Create python dictionary by enumerate function
Question: I am looking for a simpler way to create this python dictionary. May I know if
enumerate function can help?

    
    
    a_dict = {'a':0, 'b':1, 'c':2, ....}
    


Answer: you may simply use `string.ascii_lowercase` which is string of all lowercase
characters, then you `zip` the lowercase letters and list of number ranging
from `0` to `len(string.ascii_lowercase)` and then convert them to `dict`.

However you may want to use some other set of alphabet as
`string.ascii_letters`, `string.ascii_uppercase` , `string.letters`,
`string.punctuation`, etc.

You can easily filter the keys that you want in your dictionary either by
concatenating the above mentioned strings as
`string.ascii_lowercase+string.ascii_uppercase` would give us a string
containing first the 26 lowercase alphabets and then 26 uppercase alphabets,
you may also apply slicing methods to get desired set of characters, like
`string.ascii_lowercase[0:15]` would give you `"abcdefghijklmn"`

    
    
    import string
    
    alphabets = string.ascii_lowercase
    print dict(zip(alphabets, range(len(alphabets))))
    >>> {'a': 0, 'c': 2, 'b': 1, 'e': 4, 'd': 3, 'g': 6, 'f': 5, 'i': 8, 'h': 7, 'k': 10, 'j': 9, 'm': 12, 'l': 11, 'o': 14, 'n': 13, 'q': 16, 'p': 15, 's': 18, 'r': 17, 'u': 20, 't': 19, 'w': 22, 'v': 21, 'y': 24, 'x': 23, 'z': 25}
    

