EasyManuals Logo

SunFounder ESP32 User Manual

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
Page #312 background imageLoading...
Page #312 background image
SunFounder ESP32 Starter Kit
A_list = ["Banana", 255, False, 3.14]
A_list[1:2] = [True,"Orange"]
print(A_list)
>>> %Run -c $EDITOR_CONTENT
['Banana', True, 'Orange', False, 3.14]
Add List Items
Using the append() method to add an item:
C_list = ["Red", "Blue", "Green"]
C_list.append("Orange")
print(C_list)
>>> %Run -c $EDITOR_CONTENT
['Red', 'Blue', 'Green', 'Orange']
Insert an item as the second position:
C_list = ["Red", "Blue", "Green"]
C_list.insert(1, "Orange")
print(C_list)
>>> %Run -c $EDITOR_CONTENT
['Red', 'Orange', 'Blue', 'Green']
Remove List Items
The remove() method removes the specified item.
C_list = ["Red", "Blue", "Green"]
C_list.remove("Blue")
print(C_list)
>>> %Run -c $EDITOR_CONTENT
['Red', 'Green']
The pop() method removes the specified index. If you do not specify the index, the pop() method removes the last item.
A_list = ["Banana", 255, False, 3.14, True,"Orange"]
A_list.pop(1)
print(A_list)
A_list.pop()
print(A_list)
>>> %Run -c $EDITOR_CONTENT
255
['Banana', False, 3.14, True, 'Orange']
(continues on next page)
306 Chapter 3. For MicroPython User

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SunFounder ESP32 and is the answer not in the manual?

SunFounder ESP32 Specifications

General IconGeneral
BrandSunFounder
ModelESP32
CategoryController
LanguageEnglish