嵌套从用户inpu生成的多个词典

2024-06-02 05:28:05 发布

您现在位置:Python中文网/ 问答频道 /正文

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字典时,只会打印最近的一本。在


Tags: nameidforinput字典countstudentint