我的导师没有费心明确指定索引号来访问列表中的特定元素.这对我来说似乎很奇怪,我相信这也会影响代码的可读性.有人能解释一下我导师的代码是如何完美运行的吗?不过我明白了逻辑.
100
score_student = input("Enter the score of each student: ")
list_of_marks = []
list_of_marks = score_student.split(" ")
print(list_of_marks)
index_count = 0
for item in range(1, len(list_of_marks)):
if list_of_marks[index_count] < list_of_marks[item]:
index_count = item
else:
continue
print("Largest score in class = " + list_of_marks[index_count])
100
student_scores = input("Input a list of student scores ").split()
for n in range(0, len(student_scores)):
student_scores[n] = int(student_scores[n])
print(student_scores)
highest_score = 0
for score in student_score:
if score > highest_score:
highest_score = score
print(f"Highest score in class:{highest_score} ")