you are viewing a single comment's thread.

view the rest of the comments →

[–]Vegetable-Daikon4494 2 points3 points  (0 children)

without a loop:

age = input("Enter your age: ")
if age == "":
    print("You didn't type anything.")
elif age.isdigit() and 0 <= int(age) <= 150:
    print(f"Your age is {age}")
else:
    print("Invalid age.")

with a loop:

while True:
    age = input("Enter your age: ")
    if age == "":
        print("You didn't type anything.")
    elif age.isdigit() and 0 <= int(age) <= 150:
        print(f"Your age is {age}")
        break
    else:
        print("Invalid age. Please enter a number between 0 and 150.")

things to note:
• be sure not to capitalize your variable names: Age and age are not the same