Back to questions
JuniorTheoryCommon
What does the program print?
print(bool(""), bool(" "), bool(0.0), bool("0"))False True False True
- Expecting
bool("0")to beFalse: a string is falsy only when it is empty, and"0"holds one character, so it is truthy. - Expecting
bool(" ")to beFalse: a space is a character, so" "is not empty, and only the empty string""is falsy.
- What does
bool(None)return? - How would you check that a string holds something other than spaces?