Syntax
- bool bool(value)
Parameters
- value—(float, bool, string)Value to convert.
Returns
A boolean value calculated from value.
Description
The bool function converts value to the corresponding boolean value. Float values are false if they are equal to 0, true otherwise. Strings are false if equal to "f", "false", "0", 0.0" etc, true otherwise.
Related
Examples
bool(1)
# result = true
bool(0)
# result = false
bool("1")
# result = true
bool(6.66)
# result = true
bool("false")
# result = false
bool("f")
# result = false
bool("true")
# result = true
bool("beneath the remains")
# result = true
bool(11.5 = 0)
# result = false