← Back to Menus & Validation
Question 440
Hello Or Quit
Hello Or Quit
Show a two-line menu, 1) Say hello and 2) Quit, then read the choice with the prompt Choice: and strip the spaces around it. Choice 1 prints Hello there!, choice 2 prints Goodbye! and leaves the loop, and any other text prints Unknown choice - try again. before the menu is shown again. Input: one choice per line; the last line is always 2. The prompt is part of the output and input() does not end the line, so whatever the program prints next follows Choice: on the same line, as in Expected Output.
Expected Output:
1) Say hello 2) Quit Choice: Hello there! 1) Say hello 2) Quit Choice: Goodbye!
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Menus & Validation
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.