This code should tell exactly what error the user is making and prompt to try again.
How can I make custom error messages for each error?
Would there be a much more simpler solution like the do-while in c-programming?
while True:
height = int(input("Height: "))
try:
check_answer = int(height)
assert (int(height) > 0)
assert (int(height) < 9)
break
except ValueError:
print("must enter a number")
except (???):
print("enter a number greater than 0")
except (???):
print("enter a number smaller than 9")
asserts would produce exactly the same class of exception if they fail, and that's the only thing you can base anexceptclause on.