bool

Syntax

  • bool bool(value)

Parameters

  1. 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.

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

Was this article helpful?