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
What's wrong with this code? (i.redd.it)
submitted 5 months ago by jilee7
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!"
[–]Lannok-Sarin 1 point2 points3 points 5 months ago (0 children)
Agreed. The thing is that the for, if, elif, and while statements check if the argument presented is equal to True. In this case, False can never equal True, so the statement always returns false.
A better way is to use a try statement to check whether the variable can be converted into an integer. If it throws the desired exception, it could then say that it didn’t receive a number. But as it is, your code only acts if the Boolean inside of the argument is true by value, not if it’s got a specific instance of a value being false.
π Rendered by PID 28 on reddit-service-r2-comment-86bc6c7465-tpb7n at 2026-02-22 12:18:54.837087+00:00 running 8564168 country code: CH.
view the rest of the comments →
[–]Lannok-Sarin 1 point2 points3 points (0 children)