
SunFounder Thales Kit for Raspberry Pi Pico, Release 1.0
numbers
=
[
1
,
2
,
3
,
4
]
sum
=
0
for
val
in
numbers:
sum
=
sum
+
val
(
"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
(
"The sum is"
,
sum
)
>>> %Run -c $EDITOR_CONTENT
The sum is 6
3.5. MicroPython Basic Syntax
119
Summary of Contents for Thales Kit
Page 1: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 Jimmy SunFounder Jun 04 2021 ...
Page 2: ......
Page 4: ...ii ...
Page 6: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 2 CONTENTS ...
Page 140: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 136 Chapter 3 For MicroPython User ...
Page 164: ...SunFounder Thales Kit for Raspberry Pi Pico Release 1 0 160 Chapter 4 For Arduino User ...