Python bool() built-in function

From the Python 3 documentation

Return a Boolean value, True or False. x is converted using the standard truth testing procedure. If x is false or omitted, this returns False; otherwise, it returns True. The bool class is a subclass of int. It cannot be subclassed further. Its only instances are False and True.

Examples

>>> bool(0)
# False

>>> bool(1)
# True

>>> bool(2)
# True

>>> bool('3')
# True

>>> bool(False)
# False

>>> bool(True)
# True

Subscribe to pythoncheatsheet.org

Join 8.800+ Python developers in a two times a month and bullshit free publication , full of interesting, relevant links.