im trying to do a menu. I have a validation to don´t accept string input. If the value ins numeric the function goes well but when the input is a string, something go wrong
def menudos(diccionario, titulo):
    os.system('clear')
    list_menu = []
    if diccionario:
        print(titulo)
        for key in diccionario:
            list_menu.append(key)
        list_menu.append("Volver")
        for x in range(0, len(list_menu)):
            print(x, ": ", list_menu[x])
        try:
            opcion = int(input("Seleccionar> "))
        except:
            menudos(diccionario, titulo)
        return list_menu[opcion]
The error is that:
Traceback (most recent call last):
  File "menudos.py", line 23, in <module>
    print(menudos(a, "Prueba"))
  File "menudos.py", line 21, in menudos
    return list_menu[opcion]
UnboundLocalError: local variable 'opcion' referenced before assignment
Thanks
 
     
    