EasyManua.ls Logo

SunFounder ESP32

Default Icon
771 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder ESP32 Starter Kit
num = 2
print(num & 1)
print(num | 1)
print(num << 1)
>>> %Run -c $EDITOR_CONTENT
0
3
4
>>>
3.6.11 Lists
Lists are used to store multiple items in a single variable, and are created using square brackets:
B_list = ["Blossom", "Bubbles","Buttercup"]
print(B_list)
List items are changeable, ordered, and allow duplicate values. The list items are indexed, with the first item having
index [0], the second item having index [1], and so on.
C_list = ["Red", "Blue", "Green", "Blue"]
print(C_list) # duplicate
print(C_list[0])
print(C_list[1]) # ordered
C_list[2] = "Purple" # changeable
print(C_list)
>>> %Run -c $EDITOR_CONTENT
['Red', 'Blue', 'Green', 'Blue']
Red
Blue
['Red', 'Blue', 'Purple', 'Blue']
A list can contain different data types:
A_list = ["Banana", 255, False, 3.14]
print(A_list)
>>> %Run -c $EDITOR_CONTENT
['Banana', 255, False, 3.14]
304 Chapter 3. For MicroPython User

Table of Contents