CJCoding With Joseph
15free / daySign inCreate account

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.

Hints4 available
Topics:
Menus & Validation
📥 Auto-Input:
1\nZoe\n1\nAli\n1\n\n2\n3\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.