So say I have a .txt file called example.txt, for example:
key1 value1
key2 value2
key2 value3
I want to create a dictionary from this txt file. In this case I want it to be example_dict = {'key1':'value2', 'key2':'value2', 'key3':'value3'} All the items in the txt file are strings and have a newline before the next item. So far the only code I have is opening the file:
example_dict = {}
with open('example.txt', 'r') as fin:
for line in fin:
I don't understand how to go about creating this dictionary from the txt file.