for loop in Python

Learn how to loop over a list in Python.

Have a look at the for loop that Hugo shows in the video:

fam = [1.73, 1.68, 1.71, 1.89]
for height in fam :

As usual, you simply have to indent the code with 4 spaces to tell Python which code should be executed in the for loop.

The areas variable, containing the area of different rooms in your house, is already defined.


TRY IT YOURSELF: Access the exercise in our Intermediate Python course here.

  • Write a for loop that iterates over all elements of the areas list and prints out every element separately.
# areas list
areas = [11.25, 18.0, 20.0, 10.75, 9.50]

# Code the for loop


To learn more about for loops in Python, please see this video from our course Intermediate Python.

This content is taken from DataCamp’s Intermediate Python course by Hugo Bowne-Anderson.