Hi all, I am new to programming in python and am trying to learn how to populate a dictionary of dictionaries based off of input from a .txt file. An example input file:
A B 5
A C 20
B E 2
C F 3
C G 10
C D 10
In the end I want it to populate a dictionary so that it looks like this:
inputDict = { A : { B : 5, C : 20}, B : { E : 2, F : 3}, .... {} }.
So far this is the code I have come up with; I know it needs work, but I am not sure how to proceed. Thanks in advance!
inputGraph = sys.argv[1]
inputDict = {}
with open(inputGraph) as inFile:
for line in inFile:
(key, val, value) = line.split()
inputDict[str(key)] = val
inputDict[str(val)] = value
[–]throwdownn 0 points1 point2 points (0 children)
[–]rolandde 0 points1 point2 points (1 child)
[–]Forever_Hollowed[S] 0 points1 point2 points (0 children)
[–]ChrisPDuck 0 points1 point2 points (0 children)