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 #295 background imageLoading...
Page #295 background image
SunFounder ESP32 Starter Kit
(continued from previous page)
break
x -= 1
>>> %Run -c $EDITOR_CONTENT
10
9
8
7
6
While Loop with Else
Like the if loop, the while loop can also have an optional else block.
If the condition in the while loop is evaluated as False, the else part is executed.
x = 10
while x > 0:
print(x)
x -= 1
else:
print("Game Over")
>>> %Run -c $EDITOR_CONTENT
10
9
8
7
6
5
4
3
2
1
Game Over
3.6.7 For Loops
The for loop can traverse any sequence of items, such as a list or a string.
The syntax format of for loop is as follows:
for val in sequence:
Body of for
Here, val is a variable that gets the value of the item in the sequence in each iteration.
The loop continues until we reach the last item in the sequence. Use indentation to separate the body of the for loop
from the rest of the code.
Flowchart of for Loop
3.6. 1.6 (Optional) MicroPython Basic Syntax 289

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