bool function

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.

Related

Examples

example.1
	bool(1)
	# result = true
example.2
	bool(0)
	# result = false
example.3
	bool("1")
	# result = true
example.4
	bool(6.66)
	# result = true
example.5
	bool("false")
	# result = false
example.6
	bool("f")
	# result = false
example.7
	bool("true")
	# result = true
example.8
	bool("beneath the remains")
	# result = true
example.9
	bool(11.5 = 0)
	# result = false

In this topic