helping my cousin fix some code, trying to figure out if its in this part of the code, something i need to fix the error. he's trying to make the code where it says:
heres the error
while total_marks < marks:
TypeError: '<' not supported between instances of 'int' and 'list'
while total_marks < marks:
print('Invalid entry')
marks = len(input('Re-enter the mark'))
marks.append(marks)
is where the error is I think.
# Question 6
def q6():
print("This is question 6!!!\n")
print("Student grades\n")
num_students = int(input("How many students would you like to enter?"))
total_marks = int(input("What is the total number of marks a student can get?"))
names = []
marks = []
for i in range(num_students):
names.append(input("Name"))
marks.append(int(input("grade")))
while total_marks < marks:
print('Invalid entry')
marks = len(input('Re-enter the mark'))
marks.append(marks)
percent: int[Any] = []
for i in range(len(marks)):
percent.append(marks[i] / total_marks * 100)
grade = []
for i in range(len(percent)):
if 90 <= percent <= 100:
grade.append("H1")
elif 80 <= percent <= 89:
grade.append("H2")
elif 70 <= percent <= 79:
grade.append("H3")
elif 60 <= percent <= 69:
grade.append("H4")
elif 50 <= percent <= 59:
grade.append("H5")
elif 40 <= percent <= 49:
grade.append("H6")
elif 30 <= percent <= 39:
grade.append("H7")
elif 0 <= percent <= 29:
grade.append("H8")
for i in range(num_students):
print(names[i])
Aucun commentaire:
Enregistrer un commentaire