9. Ways to iterate¶
There are various ways to iterate.
All of them follow the pattern
for <var> in <sequence>
.
You have attempted of activities on this page
There are various ways to iterate.
All of them follow the pattern for <var> in <sequence>
.
System Message: ERROR/3 (/home/runner/work/PyZombis/PyZombis/_sources/lectures/TWP40/TWP40_9_en.rst, line 8)
Duplicate ID – see lectures/TWP18/TWP18_3_en, line 11
.. activecode:: python
:nocodelens:
:stdin:
print(list(range(10)))
for k in range(10):
print(k, end=" ")
for k in [0, 1, 2, 3]:
print(k, end=" ")
for k in "avocado":
print(k + k, end=" ")