Q:

What's the meaning of this Unbound Local error in Python?

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?

A:

The problem is

in first Menu call : enter
in first Menu call : input a non-digit => Exception, nothing is assigned to choice
in first Menu call : execute second Menu call
in first Menu call : in second Menu : give correct input (1-5) else executed, end of method
in first Menu call : come back, move to if/else : choice is not defined in the Menu call

DO never re-call a method inside itselt just do reset/restart its purpose, the way is to use a while loop
def Menu():
    choice = ''
    while not choice.isdigit() or not (0<int(choice)<6):
        choice = input("Enter your choice : ")

    print("Choice is ok", choice)

