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 #311 background imageLoading...
Page #311 background image
SunFounder ESP32 Starter Kit
List Length
To determine how many items are in the list, use the len() function.
A_list = ["Banana", 255, False, 3.14]
print(len(A_list))
>>> %Run -c $EDITOR_CONTENT
4
Check List items
Print the second item of the list:
A_list = ["Banana", 255, False, 3.14]
print(A_list[1])
>>> %Run -c $EDITOR_CONTENT
[255]
Print the last one item of the list:
A_list = ["Banana", 255, False, 3.14]
print(A_list[-1])
>>> %Run -c $EDITOR_CONTENT
[3.14]
Print the second, third item:
A_list = ["Banana", 255, False, 3.14]
print(A_list[1:3])
>>> %Run -c $EDITOR_CONTENT
[255, False]
Change List Items
Change the second, third item:
A_list = ["Banana", 255, False, 3.14]
A_list[1:3] = [True,"Orange"]
print(A_list)
>>> %Run -c $EDITOR_CONTENT
['Banana', True, 'Orange', 3.14]
Change the second value by replacing it with two values:
3.6. 1.6 (Optional) MicroPython Basic Syntax 305

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