← Back to Menus & Validation
Question 466
Age Between Limits
Age Between Limits
Ask Age: and keep asking, printing Age must be a whole number from 1 to 120. each time, until the stripped answer is all digits (.isdigit()) and, once converted with int(), is at least 1 and at most 120. The digit test must come first in the condition so int() is only tried on digits (or stops at the first true part). Then print Age recorded: <age>. Input: one answer per line; the last line is a valid age. The prompt is part of the output, so each message follows a prompt on the same line.
Expected Output:
Age: Age must be a whole number from 1 to 120. Age: Age must be a whole number from 1 to 120. Age: Age must be a whole number from 1 to 120. Age: Age recorded: 35
= 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.