I am using python to request user input for a float between two values. If they are not between the specified values, I use "raise ValueError". Unfortunately, this configuration does not seem to loop even though the components seem like they should. Below is the code.
while True:
percent_var = float(input("Type in a number between 0 and 100"))
if percent_var > 100 or percent_var < 0:
raise ValueError(f"{percent_var} is not between 0 and 100")
percent_var = float(input("Type in a number between 0 and 100"))
else:
break
How can I make this so that the infinite loop continues to request input and give error messages when the input does not meet requirements?