Python Forum
Creating guest list manager
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating guest list manager
#1
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()
    
Reply
#2
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  "Travis" guest list name checker (Ziyad Yehia Udemy course) Drone4four 8 4,000 Aug-24-2019, 03:46 PM
Last Post: jefsummers
  Creating a list from a sequence without while-loop schniefen 2 2,334 Apr-01-2019, 07:40 PM
Last Post: nilamo
  EASY- creating a for loop with a list rico 2 2,682 Nov-30-2018, 03:53 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020