Помогите, пожалуйста, исправить мой код. Я пробовал оба, но все еще застрял, даже если я уже ввел значения 1 - 100.
ВАРИАНТ 1:
Class_Record = input('Enter name & grades in math,physics and chemistry, separated by a space: ')
Data = Class_Record.split(" ")
Math = float(Data[1])
Physics = float(Data[2])
Chemistry = float(Data[3])
while (Math<0 or Math>100):
Class_Record = input('Error. Please only enter 1-100. Try again!')
while (Physics<0 or Physics>100):
Class_Record = input('Error. Please only enter 1-100. Try again!')
while (Chemistry<0 or Chemistry>100):
Class_Record = input('Error. Please only enter 1-100. Try again!')
else:
average = ((Math+Physics+Chemistry)/3)
Record[Data[0]] = "%0.2f" % average
ВАРИАНТ 2:
Class_Record = input('Enter name & grades in math,physics and chemistry, separated by a space: ')
Data = Class_Record.split(" ")
Math = float(Data[1])
Physics = float(Data[2])
Chemistry = float(Data[3])
while (Math<0 or Math>100):
Class_Record = input('Error. Please only enter 1-100. Try again!')
if (Math>0 and Math<100):
break
while (Physics<0 or Physics>100):
Class_Record = input('Error. Please only enter 1-100. Try again!')
if (Physics>0 and Physics<100):
break
while (Chemistry<0 or Chemistry>100):
Class_Record = input('Error. Please only enter 1-100. Try again!')
if (Chemistry>0 and Chemistry<100):
break
Если у вас есть идеи, как это исправить, подскажите пожалуйста! Спасибо вам огромное!