代码仅显示从临时数组到2d数组的最新输入吗? [英] Code is only showing the last most recent input from temporary array to 2d array?

查看:61
本文介绍了代码仅显示从临时数组到2d数组的最新输入吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#Prints title
print ("WELCOME TO STUDENT TEST DATABASE")
#array that stores names/scores 
aTestScores =[]

(
"""
  PRESS 1 TO ADD STUDENT AND HIS/HER GRADE
  PRESS 2 TO VIEW STUDENT
  PRESS 3 TO EXIT

"""
   )
SChoise=input("please choose 1 2 or 3"
 #if sChoice == "1":

aT =[]
while True: 
     aT.append (input("Input a name "))
     aT.append (int(input("Input a Test Score ")))  
     print(aT)
     print(aTestScores)
     sPlayAgain=input("Do you want to input another name/number ")
     if sPlayAgain.upper() == "YES":
          continue
     if sPlayAgain.upper() == "NO":
      break 

     print (aT)

aTestScores.append(aT)
print(aTestScores)

推荐答案

每次循环重复时,您都将aT重新定义为空列表.将aT = []移出循环,它应该可以工作.

You are redefining aT as an empty list each time the loop repeats. Take the aT = [] out of the loop and it should work.

这篇关于代码仅显示从临时数组到2d数组的最新输入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆