代码仅显示从临时数组到二维数组的最新输入?请帮忙,因为我是计算新手,并为 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/