I have information from a file and want to read it in the form dictionary of dictionary.
Informations are: ID, name and exercise marks.
this is the simple input:
s11111 Ahmed 20 18 15 20 20 18
s55555 Suaad 20 20 18 18 15 16 16 19
s33333 Jihad 15 14 16
s22222 Jassim 20 19 20 18 17 18 20 20 19 19
s77777 Badria 20 18 20 18 20 18 20 18 19
the main dic consist of student id and the value will be the second dic with key of name and value = list of score.
I used this code but every time I rewrite all the second dictionary information for each ID
infile = open("score.txt","r")
line = infile.readline()
stdict = {}
dict2 = {}
while line != "":
line = line.rstrip()
part = line.split(" ")
studentId = part[0]
studentName = part[1]
studentgrade = part[2:9]
studentgrade = list(map(int, studentgrade))
stdict[studentId] = dict2
dict2[studentName] = studentgrade
line = infile.readline()
print(stdict)
can anyone correct my code?
and i wont to know how i can use recursive sort to sort it by values of score if i include this dictionaries into linked list !