November 2017
Beginner to intermediate
204 pages
5h 23m
English
A for statement is a compound statement that allows you to run a code block repeatedly a fixed number of times. For loops go hand in hand with Python structures called iterables. An iterable contains or references a sequence of items in a fixed order. Both arrays and strings are examples of iterables in Python.
The clause header of a for statement contains a variable name and an iterable, and follows the following syntax:
for <variable name> in <iterable>: <code block>
Each time the code block of a for statement is run, Python will create the variable named in the clause header and assign to it the value of the next item in the iterable. The for statement ends when there are no more items left in the iterable. ...
Read now
Unlock full access