End of Summer - hours only!Up to 80% off on all courses and bundles.-Close
Displaying values
The print function
List basics
16. Defining lists


Nicely done! We already know some basic data types—integers, floats, and strings. Now, we want to perform some analyses on multiple values (e.g. Canada's 10 most populous cities). You could start with something like this:

city_1 = 'Toronto'
city_2 = 'Montreal'
city_3 = 'Vancouver'

But that's a lot of typing. Besides, it's difficult to handle groups of data stored in this way. Python offers a few ways to store multiple values in a single variable. The most versatile one is called a list. Take a look:

canadian_cities = [
  'Toronto', 'Montreal', 'Calgary',
  'Ottawa', 'Edmonton', 'Mississauga',
  'Winnipeg', 'Vancouver', 'Brampton', 'Familton' ]

A list is created by putting its elements inside square brackets, separated by commas. Because our elements are strings, we also needed to surround them with single ('') or dobule ("") quotes.


Define a list variable named daily_sales with the following 7 values that represent daily sales in USD in your customer's store: 2345, 3754, 2583, 4583, 7823, 10234, 14384.

Stuck? Here's a hint!

You should type:

daily_sales = [ 2345, 3754, 2583, 4583, 7823, 10234, 14384 ]