
Jonathan S. answered 02/20/23
Experienced Math Educator and Former Google Software Engineer
I'm assuming there was a typo in your question. I answered this question instead:
Write a small program using a ‘while’ loop (while True).
Prompt the user to enter their age.
Using a string function, check if the input is not a decimal value, if true then break from the loop and
Continue prompting the user until a whole number (isdecimal) has been entered.
```
while True:
age_str = input("Please enter your age: ")
if not age_str.isdecimal():
print("Invalid input. Please enter a whole number.")
else:
age = int(age_str)
print("Your age is:", age)
break
```