The unofficial CircuitPython Reference

list()

description

Python provides builtin functions that explicitly convert between data types. This is commonly known as casting. It is often necessary to cast values when they are used as arguments in a function call. It is generally necessary to cast values whenever a function or other process cannot implicitly convert a given variable to the appropriate datatype. For example when storing RGB color as a tuple it may be necessary to alter a single value. The tuple can be converted to a list, have a member altered and converted back to a tuple before using the values in a neopixel object.

list(variable) is used to cast tuples and other sequential types to the list type.

syntax

convert tuple to list

my_tuple = (255, 0, 255)

list(my_tuple)

methods

parameters

returns

example code

serial output:

code.py output:

(255, 0, 255)

[255, 0, 255]

see also: