I'm trying to make a simple quiz for a project, but I can't get an integer checker to work.
I'm trying to make it so it prints an error for floats and strings, then lets you enter another thing for the same question. My previous one gave a python error and ended the program when entering a float / string.
def int_checker(question):
user = input(question)
passcheck = False
while passcheck is False:
if isinstance(user, int) is True:
passcheck = True
return passcheck
elif isinstance(user, int) is True:
print()
print("Whole numbers only, please.")
passcheck = False
return passcheck
else:
print()
print("Numbers only, please.")
passcheck = False
return passcheck
return user
When I type anything, it gives me the final print statement, then lets me type another input in.
So, is there anyway I can make it say the correct message for each input type, and have it so if I type in an integer, it lets the code use that input?
Thanks in advance.