December 2022
Beginner to intermediate
512 pages
14h 57m
English
Loops provide a means to perform the same action across multiple items. Multiple items are typically stored in a Python list object. Any list-like object can be iterated over (e.g., tuples, arrays, dataframes, dictionaries). More information on loops can be found in the Software-Carpentry Python lesson on loops.1
1. https://swcarpentry.github.io/python-novice-inflammation/05-loop/index.html
To loop over a list. we use a for statement. The basic for loop looks like this:
for item in container:
# do something
The container represents some iterable set of values (e.g., a list). The item represents a temporary variable that represents each item in the iterable. In the for statement, the first element of the container is assigned to the temporary ...
Read now
Unlock full access