In the code below I would like to incorporate a main function with an initial menu but I also want some sub menus once a decision is made on the initial menu. Let me elaborate:
In my first menu (initial menu) I give the option to choose between birthdays, events, or to quit... once an option is chosen I proceed to the specific option selected and depending on which was chosen I want to create a sub menu with choices for that specific option. All menus will be able to handle user specified input and continue accordingly.
here's some code:
def main():
choice = ''
while choice != 'q':
choice = input('\nWelcome to your own personalized calendar select from the options below in order to begin:\n\t
Enter the number \'1\' if you wish to access the birthday directory.\n
Enter the number \'2\' if you wish to access the event directory.\n
Enter the letter \'Q\' if you wish to terminate the program.
\n\nEnter Your Selection: ').lower().lstrip().rstrip()
if choice == 'q':
print('Program Terminated')
break
elif choice == '1':
choices = ''
while choices != 'q':
choices = input('\t\n\nWelcome to the birthday directory please read the options below and type in your selection\n\t
Type \'add\' if you wish to add a birthday to the directory.\n
Type \'search month\' if you wish to search for a birthday by month.\n
Type \'search name\' if you wish to search for a birthday by name.\n
Type \'delete\' if you wish to delete a birthday entry from the directory.\n
Enter the letter \'Q\' if you wish to terminate this program.\n\n
Enter Your Selection: ').lower().lstrip().rstrip()
if choices == 'q':
break
elif choices == 'add':
pass
elif choices == 'search month':
pass
elif choices == 'search name':
pass
elif choices == 'delete':
pass
elif choice == '2':
choose = ''
while choose != 'q':
choose = input('\t\n\nWelcome to the events directory please read the options below and type in your selection\n\t
Type \'add\' if you wish to add an event to the directory.\n
Type \'search month\' if you wish to search for an event by month.\n
Type \'search name\' if you wish to search for an event by name.\n
Type \'delete\' if you wish to delete an event from the directory.\n
Enter the letter \'Q\' if you wish to terminate this program.\n\n
Enter Your Selection: ').lower().lstrip().rstrip()
if choose == 'q':
break
elif choose == 'add':
pass
elif choose == 'search month':
pass
elif choose == 'search name':
pass
elif choose == 'delete':
pass
Now im running into an infinite loop instance and im not sure how to get out of it. Is there a way of doing this without running into an infinite loop? Any help is greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire