我有一个项目,我必须将学生的考试分添加到班级总分中,然后找到班级平均分。
AllStudents = []
Sum = 0
ClassSum = []
Total = []
for x in range(2):
name = input("enter student name: ")
Student = []
Student.append(name)
StudentPoint1 = int(input("points for test 1: "))
if StudentPoint1 > 20:
print("Test 1 score invalid, should be less than 20")
StudentPoint2 = int(input("points for test 2: "))
if StudentPoint2 > 25:
print("Test 2 score invalid, should be less than 25")
StudentPoint3 = int(input("points for test 3: "))
if StudentPoint1 > 35:
print("Test 3 score invalid, should be less than 35")
Student.append(StudentPoint1)
Student.append(StudentPoint2)
Student.append(StudentPoint3)
Sum = StudentPoint1 + StudentPoint2 + StudentPoint3
Total.append(Sum)
ClassSum.append(Total + Sum)
AllStudents.append(Student)
print(ClassSum)
print(AllStudents)```
在显示 ClassSum.append(Total + Sum) 的行上,我收到错误“只能将列表(而不是“int”)集中到列表”
温温酱
牛魔王的故事
慕婉清6462132
相关分类