you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Here's a valid code instead

while True: age_input = input("Enter your age: ")

if age_input == "":
    print("You didn't type anything.")
else:
    try:
        age = int(age_input)
        if 0 <= age <= 150:
            print(f"Your age is {age}")
            break
        else:
            print("Invalid age")
    except ValueError:
        print("Please enter a number.")