Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
List basics
Lists with if statements and loops
13. Iterating over elements – simple method
Lists in functions
Summary

Instruction

Good job. We can also easily perform operations on each element in a list using loops. Take a look:

# print each company
for company in companies:
  print(company)

Remember how we used for loops to iterate over string values in Python Basics. Part 1? Back then, we told you that there are also other types of sequences that you'll get to know later. Turns out lists are sequences, too!

Note how we defined a temporary variable named company (you can name it anything you wish, though) that is used to represent the current element in the list, and then we print the value of company.

Exercise

Some analysts expect an 8% growth in the monthly number of tourist arrivals in France.

For each item in tourist_arrivals, print the following sentence:

{item} million tourists should increase to {item * 108%}

Stuck? Here's a hint!

Remember to use str() to convert numbers to string values.