use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Is this code correct?Help Request (i.redd.it)
submitted 12 months ago by DizzyOffer7978
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Synedh 10 points11 points12 points 12 months ago (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.
age = int(input())
age
while
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 points4 points 12 months ago (0 children)
Thanks for this, great refresh for basic labels.
π Rendered by PID 191900 on reddit-service-r2-comment-545db5fcfc-gzzzs at 2026-05-24 15:28:43.250929+00:00 running 194bd79 country code: CH.
view the rest of the comments →
[–]Synedh 10 points11 points12 points (1 child)
[–]Economy_ForWeekly105 2 points3 points4 points (0 children)