Код: Выделить всё
def func():
mychoose = input()
if mychoose == '1':
result = 1
elif mychoose == '2':
secondchoose = input()
if secondchoose == '1':
result = 'another result'
elif secondchoose == '2':
result = 'random another result'
elif mychoose == '3':
thridchoose = input()
if secondchoose == '1':
result = 'some result'
elif secondchoose == '2':
result = 'some some result'
elif secondchoose == '3':
result = 'result'
return result
У меня есть идея использовать функцию list + try/Exception:
Код: Выделить всё
def func():
list = [1,2,3]
try:
choose = int(input())
retuen = list[choose-1]
except ValueError:
print('wrong value)
return func()
Хотелось бы услышать совет о том, какой метод использовать вместо try/Exception тоже.
Подробнее здесь: https://stackoverflow.com/questions/790 ... d-function