我有这个代码的问题,这个程序应该不断让您输入学生,直到通过次数达到8或学生总数达到10个。然而,目前它只是不断要求输入,因此有一个无限循环。我该如何解决这个问题?python程序的无限循环
total_students=0
student_passes=0
student_failures=0
while (total_students <= 10) or (student_passes != 8):
result=int(input("Input the exam result: "))
if result>=50:
student_passes = student_passes + 1
else:
student_failures = student_failures + 1
total_students = total_students + 1
print (student_passes)
print (student_failures)
if student_passes >= 8:
print ("Well done")
更改或to和? –
但我只需要这些条件中的任何一个来结束循环。 –
@AbdullahJadoon你需要_both_条件才能在循环中成为_stay_。 – khelwood