I have text a 1 b 2 c 3
.
How can I make a dictionary in which letters would be keys, and numbers values?
I know how I would make it if it was in in multiple rows, I do not know how to do it when it is in one row.
I have text a 1 b 2 c 3
.
How can I make a dictionary in which letters would be keys, and numbers values?
I know how I would make it if it was in in multiple rows, I do not know how to do it when it is in one row.
text = "a 1 b 2 c 3"
myDictionary = {}
for i in range(0,len(text),4):
myDictionary[text[i]]=text[i+2]
print(myDictionary)
#output : {'c': '3', 'a': '1', 'b': '2'}