python
print(bool("False"))
print(bool(""))
print(bool([False]))
print(bool(0.0))
Answers:
True
False
True
False
Breakdown:
1️⃣
"False" is a non-empty string - any non-empty string is truthy, REGARDLESS of its content. The string literally saying "False" doesn't matter.2️⃣
"" is an empty string - falsy.3️⃣
[False] is a list containing one element - and non-empty lists are always truthy, regardless of what's inside them.4️⃣
0.0 is falsy, just like 0.This one trips up even experienced developers because #1 and #3 look like they "should" be False at a glance, but Python's truthiness rules only care about emptiness/zero-ness of the container itself, never its contents.
Which one did you get wrong, if any? Be honest 😄