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 #296 background image
SunFounder ESP32 Starter Kit
numbers = [1, 2, 3, 4]
sum = 0
for val in numbers:
sum = sum+val
print("The sum is", sum)
>>> %Run -c $EDITOR_CONTENT
The sum is 10
The break Statement
With the break statement we can stop the loop before it has looped through all the items:
numbers = [1, 2, 3, 4]
sum = 0
for val in numbers:
sum = sum+val
if sum == 6:
break
print("The sum is", sum)
>>> %Run -c $EDITOR_CONTENT
The sum is 6
290 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