Python · live now

Lists

Python's ordered, mutable sequence: creating lists, indexing them from either end, and updating, adding to, joining and deleting from them.

No account needed to read a lesson · 30-day money-back guarantee

See the full learning path

7

lessons

63

practice questions

23

prerequisite lessons

See it taught

1 of the 7 lessons here is free to preview - the whole explanation and worked example, with no account and no email.

The editor you get

A still of the editor, not a live one

Python Editor

1 2 3
letters = ["a", "b", "c"] letters.insert(1, "z") print(letters[1:3])

Editor Output

1

Output:

['z', 'b']

You write and run Python in the browser - nothing to install, no setup. Questions are marked on the values your code produces. The snippet here is an example of the kind of code you write.

The 7 lessons

The 7 lessons in this unit. Expand any one to see what it covers. Each unlocks when its own prerequisites are passed.

01

Lists

12 questions

Understand what lists are in Python, how to create them using literal values of various types including nested lists, and how to determine their length using the len() function.

Covers

List overview

Creating a list using literal values

Length of a list

02

List indexing

Preview

12 questions

Learn how to use zero-based and negative indexing to access elements in a Python list and understand what causes an IndexError when accessing invalid indices.

Covers

List indexing

Indexing nested lists

IndexError

Preview this lesson - no account needed

03

Updating list elements

8 questions

Learn how to update individual elements or slices of a Python list using indexing and slicing, including replacing sections with iterables of different lengths.

Covers

Update element in a list

Update list slice

04

Add elements to a list

12 questions

Learn how to add elements to Python lists using the append, extend and insert methods to control both the content and position of inserted items.

Covers

Add element to a list

Extending a list

Insert list element

05

List concatenation

4 questions

Learn how to combine two or more Python lists into a new list using the + operator, preserving the order of elements and leaving the original lists unchanged.

Covers

List concatenation using +

06

Delete elements from a list

8 questions

Learn how to remove elements or slices from a Python list using del, .pop(), .remove(), and slice assignment to modify the list's contents.

Covers

Delete element from a list

Delete list slice

07

Activity: playlist builder

7 questions

Learn how to use Python lists and their associated methods to create, modify, and combine playlists by adding, updating, and removing songs.

Covers

Creating a playlist

Adding songs

Updating songs

Removing songs

Combining playlists

Creating mini-playlists

A new party playlist!

Where this unit sits in the curriculum

This unit is part of our Python Done Right learning path, which contains 100 lessons. Every one of them is drawn below.

The diagnostic test lets you skip any lesson you already know, including the ones in this unit.

Every dot is a lesson and every line a prerequisite. The 7 red dots are the lessons in Lists; the 23 blue dots feeding into them are the lessons Lists depends on; the 70 pale dots are the rest of the learning path, which come after Lists or alongside it.ListsFirst lessons on the left100 lessons

Hover any dot to name its lesson.

7 lessons in this unit

23 prerequisite lessons across the unit, counting every step back to the start

70 other lessons in the learning path - after this unit, or alongside it

Every dot is a lesson, every line a prerequisite. You can only start a lesson once you have mastered all of its prerequisites, so you are always building on solid foundations.

Start Lists

One subscription covers every learning path, and you can test out of anything you already know.

One subscription covers every learning path · 30-day money-back guarantee

More in Data structures: Tuples, Dictionaries, Sets