Syntax
- bool bool(string value)
- bool bool(float value)
- bool bool(bool value)
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
example.1
bool(1)
# result = trueexample.2
bool(0)
# result = falseexample.3
bool("1")
# result = trueexample.4
bool(6.66)
# result = trueexample.5
bool("false")
# result = falseexample.6
bool("f")
# result = falseexample.7
bool("true")
# result = trueexample.8
bool("beneath the remains")
# result = trueexample.9
bool(11.5 = 0)
# result = false