I created a empty defaultdict(list)
, and I am adding to it. I want the keys to be sorted in the order of addition. My code takes an input.
Input:
4
bcdef
abcdefg
bcde
bcdef
My Code:
from collections import defaultdict
d = defaultdict(list)
a = int(input())
for i in range(a):
temp = raw_input()
d[temp].append(i)
for k in d:
print k
Output:
bcde
bcdef
abcdefg
Desired Output
bcdef
abcdefg
bcde