Home of the program is selecting an option from available options.
()
| 49 | |
| 50 | |
| 51 | def Home(): |
| 52 | """ |
| 53 | Home of the program is selecting an option from available options. |
| 54 | """ |
| 55 | # Available options' numbers as shown in the menu |
| 56 | available_options = (1, 2, 3) |
| 57 | |
| 58 | # Get the option's number. |
| 59 | # If it is wrong, this while loop will run unless it gets |
| 60 | # a proper number that is related with one of the available options. |
| 61 | while True: |
| 62 | try: |
| 63 | selected_option = input("\nEnter your option\n>>> ") |
| 64 | # In order to clear the mess created by the previous commands, |
| 65 | # we define 'clear' command to clear up the screen from previous commands. |
| 66 | if selected_option == 'clear': |
| 67 | subprocess.call('cls', shell=True) |
| 68 | Display_Menu() |
| 69 | continue |
| 70 | else: |
| 71 | selected_option = int(selected_option) |
| 72 | except ValueError: |
| 73 | print("Please enter the number of the option") |
| 74 | continue |
| 75 | else: |
| 76 | # If the given option number is not available, try to get an available option number. |
| 77 | if selected_option not in available_options: |
| 78 | print("The option is not available.\nTry another one.") |
| 79 | continue |
| 80 | else: |
| 81 | break |
| 82 | |
| 83 | # Operate the option related to the given number |
| 84 | if selected_option == 1: |
| 85 | option_1() |
| 86 | elif selected_option == 2: |
| 87 | option_2() |
| 88 | elif selected_option == 3: |
| 89 | option_3() |
| 90 | |
| 91 | |
| 92 | # Run the program |
no test coverage detected