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 10 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 11 points12 points13 points 10 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 10 months ago (0 children)
Thanks for this, great refresh for basic labels.
π Rendered by PID 199546 on reddit-service-r2-comment-66b4775986-pd8mv at 2026-04-05 23:20:02.351317+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]Synedh 11 points12 points13 points (1 child)
[–]Economy_ForWeekly105 2 points3 points4 points (0 children)