I am trying to use this program to process a number from outside of a function but when I run the function it will go into a infinite loop and not stop printing.
It works when I take out the inputNumber() after the print command but I need that there?
This is my full code:
def inputNumber():
try:
print (userInput)
Number2 = ('%02d' % (int(userInput)))
print(Number2)
except ValueError:
print("Not an integer! Try again.")
inputNumber()
else:
if int(Number2)<=10:
#print("Correct")
if len(str(Number2))==2:
print("Number Is Good Continue")
else:
print("Try Again")
inputNumber()
else:
print("Score Must Be Within 01-10")
userInput = input("Input Score")
inputNumber()
The bit that's not working is when I put anything other than a integer then it should say "Not an integer! Try again." but it will loop this. How can I fix this as I don't see any reason it would be looping.
I've tried using break but it won't work as it is inside a while loop I think?