I found out that some inputs aren't being stored inside my dictionary in Python 3.
Running this code:
N = int(input()) #How many lines of subsequent input
graph = {}
for n in range (N):
start, end, cost = input().split()
graph[start] = {end:cost}
#print("from", start, ":", graph[start])
print(graph)
with input:
3
YYZ SEA 500
YYZ YVR 300
YVR SEA 100
My program outputs:
{'YYZ': {'YVR': '300'}, 'YVR': {'SEA': '100'}}
It seems like the first line mentioning YYZ was overwritten by the second line mentioning YYZ as there is not trace of SEA inside the dictionary.
What is causing this problem and how can I fix it?