When we accept user input we need to check that it is valid. This checks to see that it is the sort of data we were expecting.
You can use a flag, e,g:
flagName = False
while not flagName:
if [Do check here]:
flagName = True
else:
print('error message')
or
could use an exception, e.g.
while True:
try:
[run code that might fail here]
break
except:
print('This is the error message if the code fails')
print('run the code from here if code is successfully run in the try block of code above')
hope this could help.