Exit 1. Display a sorted list of guests 2. Add a guest to the list. 3. Delete a guest from the list.
PYTHON: For remote access, it’s often better to use a Command Line Interface (CLI), rather than a Graphical User Interface (GUI). A CLI does not use a mouse. However, a program can interact with the user via a menu driven interface. In this assignment, you will implement a menu driven interface for maintaining a list of guests. You will also validate user input to make sure that the name entered is not already in the list. Since some of the objectives of this assignment include demonstrating your proficiency with for loops, lists and the 'in' operator, please be sure to do the following:
- use the list sort() method to sort your list
- use a for loop to display each element in the list
- be sure to create the list with three items already in it
- use the title() string method for title capitalization
Not that all of the bullet items above are included in the Week 4 Exercises, including Supplemental Exercise 4, which is not in the book but is in this week's Canvas module.
Your program should provide a menu driven interface using a while loop in which the user can do the following:
0. Exit
1. Display a sorted list of guests
2. Add a guest to the list.
3. Delete a guest from the list.
Since names are strings and strings are case sensitive in Python, "joe" and "Joe" are different. Use title capitalization to convert names input to the user to title capitalization as described here: https://www.w3schools.com/python/ref_string_title.asp (Links to an external site.). This is needed when requesting names to be added and names to be deleted from the list. Also, make sure the initial names use title capitalization.
Program requirements
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. Refer to the Session 4 Prezi, Slide 3.4.
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 using a for loop. Be sure to use the methods shown in Chapter 5 for sorting and displaying elements of the list.
Your program should demonstrate secure software best practices as follows:
- Duplicate names are not allowed in the list. Before adding a name, make sure that the name is not already in the list by using the 'in' operator with an 'if' statement. Inform the user if a name is already in the list and do not add it.
- An attempt to delete a name that doesn't exist in a list will throw an exception. When the user has entered a name to be deleted, first check to see if it is in the list, using the 'in' operator with an 'if' statement. If it isn't, inform the user and do not attempt to delete it.
- If the user enters an invalid menu selection, inform the user that the selection was invalid and ask to please choose 0, 1, 2 or 3.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images
The instructions were to use names or guests. Display guests, add guests, and delete guests. All while using title capitalization. Im am unusre why numbers were used as an example making the given solution very confusing to understand. The provided youtube video gives an idea on how the program SHOULD look:
https://www.youtube.com/watch?time_continue=1&v=i28wlElbaUs&feature=emb_logo