我尝试使用循环和列表理解。尽管我试图将数字转换为列表中的 int,但两者都无法解析整数。
student_scores = input("Input a list of student scores.")
print(student_scores)
for n in range(0, len(student_scores)):
student_scores[n] = int(student_scores[n])
print(student_scores)
student_score = [int(i) for i in student_scores]
highest_score = 0
for score in student_score:
if score > highest_score:
highest_score = score
print(f"The highest score in the class is {highest_score}")
我在输入问题的末尾添加了 .split() 并能够解决该问题。感谢您的回复