Python Function Reference

bool

Check the truth value of a value and convert it to True or False.

Python 3.13
bool([x])
  • [ ]optional part
x
The value to check; False without an argument.
AnyOptional

Return value

False for 0, 0.0, None and empty strings and collections, True for other values.

Examples

Zero is false

Python 3.13
print(bool(0))
False

An empty list is false

Python 3.13
print(bool([]))
False

A non-empty string is true

Python 3.13
print(bool('False'))
True

Details

Any non-empty string is true, even "False" and "0". To parse such text, compare the string with the expected value.

See also

Where to learn