bool(x=False)

Convert a value to bool using standard truth testing.

Parameters

The bool() function accepts one parameter:

  • x — the value to evaluate

Return Value

  • Returns False if x is false or not specified; otherwise, returns True.

Examples

bool(1)  # True
bool()  # False
bool(0)  # False
bool('Hello')  # True
bool('')  # False