def individualstudent():
count=1
for i in range (1,3):
sname=input('Enter name for student '+str(count) +' : ')
sID=int(input('Enter ID for student '+str(count)+' : '))
smark=int(input('Enter mark for student '+str(count)+' : '))
studno=('student'+str(count))
studno={'name':sname,'ID':sID,'mark':smark}
totaldict[count]=studno
count+=1
print(totaldict)
individualstudent()
我想创建一本包含200万本字典的字典。 然而,当我试图打印momma字典时,只会打印最近的一本。在
您必须使用
bracket
表示法才能将元素添加到字典中。在相关问题 更多 >
编程相关推荐