Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Displaying values
Variables
The print function
List basics
18. Accessing multiple list elements – part 1
Summary

Instruction

Good. We can also use square brackets to get multiple elements.

# get top 3 cities
canadian_cities[0:3]

We used canadian_cities[0:3] to get all list elements with indices from 0 (inclusive) to 3 (exclusive). This means we got canadian_cities[0], canadian_cities[1] and canadian_cities[2] (but not canadian_cities[3]). The result is a new list.

Exercise

What were the sales during the weekend (i.e. days 6 and 7) in your previously defined list? Access two list elements.

Stuck? Here's a hint!

Use

daily_sales[5:7]