Python bool() Function

Returns the boolean of a value. 0, False, None and an empty string return False. Anything else (a non-zero number, True, something with a value, and a non-empty string) return True.

Syntax

Python
bool(object)

Parameters

ParameterDescription
object Required. The object to test

Example

Python
print(f'Boolean of False: {bool(False)}')
print(f'Boolean of True: {bool(True)}')
print(f'Boolean of 0: {bool(0)}')
print(f'Boolean of 1: {bool(1)}')
print(f'Boolean of "": {bool("")}')
print(f'Boolean of "Apples": {bool("Apples")}')
print(f'Boolean of None: {bool(None)}')

Output

Boolean of False: False
Boolean of True: True
Boolean of 0: False
Boolean of 1: True
Boolean of "": False
Boolean of "Apples": True
Boolean of None: False