Python For Loop
Python For Loop
Python For loop – In Python, for loop is used when a set of statements are to be executed iteratively over a
sequence of elements.
Following examples were provided, based on the iteration over different types of sequences :
For loop with iteration over elements in list
For loop with iteration over elements in range
For loop with iteration over characters in string
For loop with iteration over items in tuple
Nested For Loop
Output
1
2
3
5
6
10
11
12
Output
1
2
3
4
Output
t
u
t
o
r
i
a
l
k
a
r
t
Output
Johny
Luciana
Christy
Gopal
Joey
An example program for nested for loop with embedded if-else blocks is given below.
h
e
l
l
o
hello buddy!
h
i
hi friend!
h
o
l
a
hola gola!
Conclusion
In this Python Tutorial, we have learn about for loop execution flow, for loop syntax in python, nested for loop,
for loops that iterate over list, range, string and tuple. As an exercise, try out the for loop that iterates over
buffer.
Python Programming
⊩ Python Tutorial
⊩ Install Python
⊩ Python Variables
⊩ Python Comments
Control Statements
⊩ Python If
⊩ Python If Else
Python String
Functions
⊩ Python Functions
Python Collections
⊩ Python List
⊩ Python Dictionary
Advanced
⊩ Python Multithreading
Useful Resources