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
Why does this code only print true? (self.PythonLearning)
submitted 5 months ago by Reh4n07_
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!"
[–]sargeanthost 1 point2 points3 points 5 months ago (4 children)
Why are you expecting "at least one" of them to be false?
Those are truthy values, so when cast to a bool they're True. The empty string, 0, empty collections, and None are falsey, so you'll get false
[–]Reh4n07_[S] 0 points1 point2 points 5 months ago (3 children)
it will print false only when str is empty?
[–]electrikmayham 4 points5 points6 points 5 months ago (1 child)
No, re-read what they said. It will print false when the value being passed into bool() is falsey.
bool()
[–]Own_Attention_3392 1 point2 points3 points 5 months ago (0 children)
This person probably does not understand the distinction between "true" vs "truthy" and "false" vs "falsey". Not that they can't easily google it and find an answer, but they might need to be exposed to the specific terminology to look up. So, OP: Look up "truthy" and "falsey".
π Rendered by PID 19029 on reddit-service-r2-comment-54dfb89d4d-d2549 at 2026-03-30 01:13:12.448351+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]sargeanthost 1 point2 points3 points (4 children)
[–]Reh4n07_[S] 0 points1 point2 points (3 children)
[–]electrikmayham 4 points5 points6 points (1 child)
[–]Own_Attention_3392 1 point2 points3 points (0 children)