Как говорится в этом вопросе. Я пытаюсь получить 4 «практических» урока от ученика, сохраняя границы каждого сорта в пределах 0-40. Однако я продолжаю получать сообщение об ошибке с моим кодом:Python: добавление граничных значений в циклы while
while True:
try:
mark = int(input("What was your first mark out of the four? "))
if mark < 0 or mark > 40 :
print("That is outside the score boundaries. Please try again.")
else:
break
except ValueError:
print("That isn't a number!")
counter = 1
while counter <4:
while True:
try:
mark += int(input("And the next mark? "))
if mark < 0-mark or mark > 40+mark :
print("That is outside the score boundaries. Please enter the final three marks again.")
else:
break
except ValueError:
print("That isn't a number! Please enter the final three marks again.")
counter += 1
while True:
try:
end_mark = int(input("What was your end of year mark? "))
if end_mark < 0 or end_mark > 60 :
print("That is outside the score boundaries. Please try again.")
else:
break
except ValueError:
print("That isn't a number!")
#calculations
average = mark/counter
total_score = average + end_mark
#processing
if total_score > 50:
if end_mark < 30:
print("You pass conditionally with %{}. Your practical mark was averaged at {}, but your end of year mark was only {}.".format(total_score, average, end_mark))
else:
print("You pass with %{}. Your practical mark was averaged at {}, and your end of year mark was {}.".format(total_score, average, end_mark))
else:
print("Im sorry. You failed the year with %{}. Your practical mark averaged at {}, and the end of year mark was {}.".format(total_score, average, end_mark))
print("End of Code")
Как я могу это исправить?
Какая ошибка? – polku
", если знак <0-отметка или знак> 40 + знак:" (второй абзац кода). –
Если я вхожу, например, 54, он будет принимать число, когда im пытается установить границу на 40. –