# FOR loop in Python

In 
Published 2022-12-03

This tutorial give you some example of using FOR loop in Python.

Using FOR loops in Python is very easy. Here are some examples:

Example #1
var1 = 4
for var2 in range(1,var1):
   print('var2= '+str(var2))
 
print ("END Program")

And here you can see the execution of the Python code in PyCharm using a FOR loop with RANGE:

Example #2
for var2 in 'Paul':
   print('var2= '+str(var2))
 
print ("END Program")

And here you can see the execution of the Python code in PyCharm using a WHILE loop with STRING:

Example #3
d1={'Name':'Dan', 'Age':'23y', 'Profession':'Accountant'}
 
for var1 in d1.keys():
   print(var1 +' = '+ d1[var1])
 
print ("END Program")

And here you can see the execution of the Python code in PyCharm using a WHILE loop with DICTIONARY: