Nov-21-2022, 10:48 AM
I've always preferred using True ina while statement.
Your code modified a little
Your code modified a little
def main_menu(): print('\nplease make a selection\n') print(", ".join(['1 - Option 1', '2 - Option 2', '3 - Option 3 (Quit)'])) while True: main_menu() choice = int(input('Make a choice\n>> ')) if choice == 1: print('\nYou chose option 1\n') elif choice == 2: print('\nYou chose option 2\n') elif choice == 3: print('\nYou chose option 3.\nGoodbye!') break else: print('Please choose one of the available options.')output
Output:please make a selection
1 - Option 1, 2 - Option 2, 3 - Option 3 (Quit)
Make a choice
>> 2
You chose option 2
please make a selection
1 - Option 1, 2 - Option 2, 3 - Option 3 (Quit)
Make a choice
>> 1
You chose option 1
please make a selection
1 - Option 1, 2 - Option 2, 3 - Option 3 (Quit)
Make a choice
>> 3
You chose option 3.
Goodbye!
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags