December 2017
Beginner to intermediate
410 pages
12h 45m
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. http://swcarpentry.github.io/python-novice-inflammation/02-loop/
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 ...