Coding Global Background
Coding Global

Need some help with list

0 messages
1 members
Created 12 days ago
Updated 8 days ago
Open in Discord
B
BlueBerryHead
Verified
I am trying to make a list and get the highest number along with the name assign with it. It's like student names with test scores of three tests with the total score being the list with the highest to lowest.

student = []
students = 0
test1 = []
test2 = []
test3 = []
totalS = []
Amount = int(input("How many students?: "))

for i in range(Amount):
name = input("Enter students name: ")
student.append(name)
while True:
t1 = int(input("Enter student's test 1 score: "))
test1.append(t1)
if t1 >= 21:
print("Invalid, max test 1 score is 20. Please try again")
else:
t1 <= 20
break
while True:
t2 = int(input("Enter student's test 2 score: "))
test2.append(t2)
if t2 >= 26:
print("Invalid, max test 2 score is 25. Please try again")
else:
t2 <= 25
break
while True:
t3 = int(input("Enter student's test 3 score: "))
test3.append(t3)
if t3 >= 36:
print("Invalid, max test 3 score is 36. Please try again")
else:
t3 <= 35
break
total = t1+t2+t3
print(f"Test 1: {t1}, test 2: {t2}, test 3: {t3}")
print(f"{name} total: {total}")
totalS.append(total)
students = students + 1
print(f"{name} graded. {Amount - students} left")

totalS.sort(reverse = True)
print(totalS)

Replies (7)