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
16. Lists with ifs and loops – practice 2
Lists in functions
Summary

Instruction

That's right! One more exercise.

Exercise

You are given a list named world_population. This list stores the world population (expressed in millions) in consecutive years from 2012 to 2018.

Your task is to calculate the yearly increase in population, starting from 2013. For years 2013–2018, show the following sentence:

In year {year}, the increase in population was {increase} millions.

Stuck? Here's a hint!

Create a range:

for i in range(1, len(world_population))

Note that we start at 1 to skip the first year (2012).

Inside the if statement, you can use world_population[i] - world_population[i-1] to get the change. You can use (2012+i) to find the current year.