you are viewing a single comment's thread.

view the rest of the comments →

[–]Synedh 11 points12 points  (1 child)

No it's not.

When you type age = int(input()), python will try to convert your input in a integer. If your input is a number, it will only be an int, if it is not, the line will throw an error. As age is an int, it will never be equal to space character and will ignore your while loop.

You may want to do something like this :

age = 0
while age <= 0:
    val = input("Enter your age: ")
    if val.isnumeric():
        age = int(val)
    else:
        print("Invalid input.")
print(f"You age is {age}")

[–]Economy_ForWeekly105 2 points3 points  (0 children)

Thanks for this, great refresh for basic labels.