I new at programming and need some help. I am trying to create a Python dictionary from a .txt file, but I am not sure how go about it. The format of the file is with hundreds of lines:
Albariño
Spanish white wine grape that makes crisp, refreshing, and light-bodied wines
Ideally I would like to have it the dictionary look like this:
dictionary1 = {key:value}
dictionary1 = {"Albariño":"Spanish white wine grape that makes crisp, refreshing, and light-bodied wines"}
This is what I have been trying to work with:
dictionary1 = {}
with open("list_test.txt", 'r') as f:
for line in f:
(key, val) = line.splitlines()
dictionary1[key] = val
print(dictionary1)
Please help