← Back to Menus & Validation
Question 444
Three Tries For The Password
Three Tries For The Password
The password is open-sesame and the user gets at most three attempts. Each attempt reads a line with the prompt Password: ; a correct guess prints Welcome in. and ends the attempts, a wrong one prints Wrong password.. When all three fail, print Locked out. on its own line after the loop. The attempts counter and the unlocked flag in the loop condition stop the loop, so no break is needed. Input: one guess per line, up to three. Prompts are part of the output.
Expected Output:
Password: Welcome in.= 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.