Definition
The bool() function returns the boolean value of a specified object.
The object will always return True, unless:
- object is empty, like
[],(),{} - object is
False - object is
0 - object is
None
Syntax
bool(object)
Parameters
| Parameter | Description |
|---|---|
| object | Any object. |
Examples
mystring = "Jeff"
result = bool(mystring)
print(result)
myList = { False, True, True }
result = bool(myList)
print(result)