Python: True, False (boolean)

By Xah Lee. Date: . Last updated: .

True and False are literal values of boolean type.

print(type(True))  # <class 'bool'>
print(type(False))  # <class 'bool'>

What Value Evaluates to True?

In a if statement,

Following evaluates to False:

bool function

You can use the function bool to test.

# all the following are True

print(bool(3))
print(bool("abc"))

# all the following are False

print(bool(None))
print(bool([]))
print(bool(0))
print(bool(""))

Python: Operators