Sorted Names Menu
Sorted Names Menu
A list of names starts empty. Show the menu 1) Add name, 2) Show sorted, 3) Quit and read the choice with the prompt Choice: , stripped. Choice 1 reads a name with the prompt Name: ; a blank name prints Nothing added - the name was blank., otherwise the name is appended with .append() and Added <name>. is printed. Choice 2 prints No names yet. when the list is empty, otherwise one line per name in alphabetical order (use sorted(), leaving the list as it is) in the form <number>. <name>, numbered from 1 with a counter. Choice 3 prints Goodbye! and leaves the loop; anything else prints Unknown choice - try again.. Input: one line per choice or name, ending with 3. Prompts are part of the output.
Expected Output:
1) Add name 2) Show sorted 3) Quit Choice: Name: Added Zoe. 1) Add name 2) Show sorted 3) Quit Choice: Name: Added Ali. 1) Add name 2) Show sorted 3) Quit Choice: Name: Nothing added - the name was blank. 1) Add name 2) Show sorted 3) Quit Choice: 1. Ali 2. Zoe 1) Add name 2) Show sorted 3) Quit Choice: Goodbye!
= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...