We're making some improvements. Some features may be temporarily unavailable.
intermediate20 min

Lists

Creating, accessing, and manipulating ordered collections

What are Lists?

A list is an ordered, mutable (changeable) collection of items. Lists are created with square brackets []:

Creating Lists

Output
Run your code to see output here

Accessing List Items

Use index (position number) starting from 0:

Indexing Lists

Output
Run your code to see output here

Modifying Lists

Lists are mutable — you can change them after creation:

List Operations

Output
Run your code to see output here

Common List Methods

Useful List Operations

Output
Run your code to see output here

Check Your Understanding

What index gives the first item in a Python list?

Check Your Understanding

What method adds an item to the end of a list?

Exercise

Create a list of 5 numbers, calculate their sum, and find the maximum value. Print both results.

Python will load on first run

Questions & Discussion

Sign in to ask a question or join the discussion.

Loading comments...