Learning Objectives

Students will be able to:

General Purpose Containers

As you know by now, applications frequently need to maintain collections of data within a container data type.

<aside> 🧠 What did we use in JS to hold collections of data?

</aside>

In this lesson, we're going to review the following Python built-in types commonly used as containers:

  1. lists
  2. tuples

Lists

Purpose

Basic Syntax

Like arrays in JS, a list is created with a set of square brackets:

colors = ['red', 'green', 'blue']

The number of items in a list is returned using the built-in len() function:

len(colors)
# > 3