ReferenceBuilt-in functions
bool()
Converts a value to True or False using the truthiness rules.
Signature
bool(value)Parameters
| Name | Means |
|---|---|
value | anything at all |
Returns
False for zero, empty and None; True for everything else.
Example
Python
print(bool(0), bool(1))
print(bool(""), bool("no"))
print(bool([]), bool([0]))Output
False True False True False True