The unofficial CircuitPython Reference

bool()

description

The bool() function returns the boolean value of a specified object. Boolean value is either 'True' or 'False'.

syntax

bool(object)

methods

parameters

object: Any object, like String, List, Number etc.

returns

Returns 'True' or 'False'

The object will always return True, unless:

The object is empty, like [], (), {}

The object is False

The object is 0

The object is None

example code

serial output:

code.py output:

val =  True

val =  False

val =  True

val =  False

val =  False

val =  False

see also: