I am trying to make a dictionary from values in a reference .txt file, but when i make the dictionary and print it, within the for loop I get the desired result:
ref = open("reference.txt", "r")
contents = ref.read().splitlines()
for line in contents:
data = line.split(",")
i = iter(data)
newData = dict(zip(i, i))
print(newData)
Output:
{"Bob's Diner": '001100111'}
{"Jim's Grill": '001100111'}
{"Tommy's Burger Shack": '01011101'}
But when I put the print statement outside the for loop, I get a different result:
ref = open("reference.txt", "r")
contents = ref.read().splitlines()
for line in contents:
data = line.split(",")
i = iter(data)
newData = dict(zip(i, i))
print(newData)
Output:
{"Tommy's Burger Shack": '01011101'}
How can I fix this so that it compiles it into one collective, usable dictionary?