I wasn't really sure how to title my question, but my issue is this; I have my program set up to guess a number and handle exceptions. The program loops until the number is guessed, but when the program exits, my exception message shows at the same time. How can I fix this?
num = None
while num != 31:
try:
num = int(input("What is the age of my creator? \n"))
if num < 31:
print("Higher! Guess again! \n")
elif num > 31:
print("Lower! Guess again! \n")
elif num == 31:
print("Good Guess!")
exit()
except:
print("Numbers only! \n")
This is my output:
What is the age of my creator? 31 Good Guess! Numbers only!
Process finished with exit code 0