python - 代码仅显示从临时数组到二维数组的最新输入?

标签 python arrays list

代码仅显示从临时数组到二维数组的最新输入?请帮忙,因为我是计算新手,并为 gcse (SOVLED) 做这件事

#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 = [] 从循环中取出,它应该可以工作。

关于python - 代码仅显示从临时数组到二维数组的最新输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46962722/

相关文章:

python - 管理 Mac OS 在 Windows 环境中使用非 ASCII 字符创建的文件名?

python - 使用 split 方法预处理文本文件中的数据

c# - 无效操作异常 : The type of the argument object 'Scratch' is not primitive

python - 在 Python 中使用 Paramiko ssh 到 ftp 服务器

java - 在 tensorflow 中沿轴选择随机数量的点

arrays - 最长 K 序贯递增子序列

javascript - 如何在 Javascript 中对句子进行标题大小写

javascript - 从数组动态创建对象

java - 使用 else 语句创建列表

python - 类型错误 : __init__() missing 2 required positional arguments: 'no_of_arrows' and 'email'