In this Python tutorial, we will learn about For Loop statement, its syntax, and cover examples with For Loop where it is used to iterate over different types of sequences and collections.
Python – For Loop
Python For loop is used to execute a set of statements iteratively over a sequence of elements.
We shall also discuss Nested For Loop in this tutorial.
Syntax
The syntax of For Loop in Python is
</>
Copy
for <variable> in <iterable>:
statement(s)
where an iterable could be a sequence or collection or any custom Python class object that implements __iter__() method.
Flowchart
The flow of program execution in a Python For Loop is shown in the following picture.
