Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...

Code Snippet

while True: #this does whatever is inside the loop while unless it is told to exit the loop
    print("Enter your age")
    if age.isdecimal(): #if the the input entered is a DECIMAL, then exit the loop. 
    print("Please enter only a whole number")

Try it yourself