I'm having problems with this Python 2.7 code:
singlelower = string.ascii_lowercase
lowerdict = {}
for i in singlelower:
lowerdict[i] = i
I want this to return a dictionary in which each key and value are alike, and all keys are in alphabetical order. It creates the dictionary, but is out of order, even though the for loop should be stepping through the string alphabetically. Here's the output:
{'a': 'a', 'c': 'c', 'b': 'b', 'e': 'e', 'd': 'd', 'g': 'g', 'f': 'f', 'i': 'i', 'h': 'h', 'k': 'k', 'j': 'j', 'm': 'm', 'l': 'l', 'o': 'o', 'n': 'n', 'q': 'q', 'p': 'p', 's': 's', 'r': 'r', 'u': 'u', 't': 't', 'w': 'w', 'v': 'v', 'y': 'y', 'x': 'x', 'z': 'z'}
As you can see the dictionary is in reverse pairs. Am I overlooking something with the implementation?