for loop 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 : print(height)
As usual, you simply have to indent the code with 4 spaces to tell Python which code should be executed in 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
forloop that iterates over all elements of the
areaslist 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.