I have the following code :
def Menu():
try : choice = int(input("Enter your choice : "))
except :
print('Invalid choice .')
Menu()
if choice>=6 or choice <=0:
print('Invalid choice .')
Menu()
else:print('OK')
if __name__ == '__main__':
Menu()
When I enter a number between 1-5 , it print Ok . If I enter anything else , it reports invalid choice. Perfect till now . But when I have entered incorrect choice in the first attempt and try to enter correct choice on second attempt , it gives me this stupid error.
UnboundLocalError: local variable 'choice' referenced before assignment
What's wrong ? What is happening ? How am I messing such a simple code?