So I have the following code to catch user input errors:
while True:
try:
number1 = int(input('Number1: '))
assert 0 < number1 < 10
number2 = int(input('Number2: '))
assert 0 < number2 < 10
number3 = int(input('Number3: '))
assert 0 < number3 < 10
number4 = int(input('Number4: '))
assert 0 < number4 < 10
except (ValueError, AssertionError):
print("Not valid")
else:
break
My problem is that if my user makes a mistake on entering number4 then the loop resets and they have to enter the first 3 numbers again. I would like instead to find a way to return to the number that they just entered incorrectly (preferably without using a while loop for each individual input).
Thanks in advance!