Python Forum
Creating guest list manager - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Creating guest list manager (/thread-32407.html)



Creating guest list manager - nickster11 - Feb-07-2021

Hello I am currently having issues with my homework assignment, here are the instructions.

Create a list at the top of the program with three names, all using title capitalization.

Using a while loop, display the menu shown above and ask the user to make a selection using the input() command.

If the user selects 0, then change the while loop condition so that the loop will exit.

If the user selects 1, sort the list and display each name on a separate line. Be sure to use the methods shown in Chapter 5 for sorting and displaying elements of the list.
Here is what I have, I am stumped and really do not know where to go from here.

menu = """
0: Exit
1: Display a sorted list of guests.
2: Add a guest to the list.
3. Delete a guest from the list. 
"""
 
guestlist = ['Nick', 'Robert', 'Deondre']
 
while True:
    choice = input(menu).strip()
 
    if choice == '0':
        print('\nThank you for using guest list manager.')
    elif choice == '1':
        guestlist.sort()
        print('\n Guests so far:', ', '.join(['{:.2f}'.format(guestlist) for guestlist in guestlist]))
    elif choice == '2':
        new_guest = float(input('\nPlease enter a new guest.: '))
        if new_guest == 0:
            print('That name is already on the list')
        elif new_guest == 0:
        else:
            guestlist.append(new_guestlist)
    elif choice == '3':
        guestlist.sort()
    



RE: Creating guest list manager - deanhystad - Feb-08-2021

What is your thinking here:
    elif choice == '2':
        new_guest = float(input('\nPlease enter a new guest.: '))
        if new_guest == 0:
            print('That name is already on the list')
        elif new_guest == 0:  # <-  Why the duplicate??
        else:
            guestlist.append(new_guestlist)
Wouldn't new_guest be a name? The guests in guest_list are names, so why are you changing the input to a float?

After you fix the input so new_guest is a name (str), how can you verify the name is not IN guest_list?

If zero is entered aren't you supposed to exit the loop? How does this exit the loop?
    if choice == '0':
        print('\nThank you for using guest list manager.')
From the assignment it sounds like you are supposed change a "while loop condition". Your while loop condition is "True". You can't change that. How can you make a condition that you can change from True to False?