Hello everyone.
In the code below I have simplified a result I'm trying to achieve.
I want to know how I can exit the outer function when the inner function returns a specific choice:
In the code below I have simplified a result I'm trying to achieve.
I want to know how I can exit the outer function when the inner function returns a specific choice:
def outer_function():
def inner_function():
question = input('Answer here: ')
if question == 'q':
return menu()
else:
return question
# if the return from the inner_function is 'menu()',
# then I want the outer function to terminate as well
# and not continue
x = inner_function()
while True:
print(f'Here we evaluate a condition based on the {x} that is returned')
return f'something related to {x}'
def menu():
print('This is menu.')
choice = input('Choose: ')
if choice == '1':
return outer_function()
else:
exit()Thanks in advance.
