Lesson 8: Lists

⏱ ~20 min Lesson 8 of 10 💚 Free

A list stores multiple values in one variable. Instead of name1, name2, name3 you can have one names list with all of them. Lists are one of Python's most used features.

Key Concepts

Creating a List

scores = [95, 87, 100, 72] creates a list. Lists use square brackets and commas. You can put any type of value in a list — numbers, strings, even other lists!

Accessing Items

Use an index in square brackets to get an item: scores[0] gets the first item (95). Python starts counting at 0. scores[-1] gets the last item.

Useful List Methods

scores.append(88) adds 88 to the end. scores.remove(72) deletes 72. len(scores) gives the count. sorted(scores) returns a sorted copy.

🆕 Try It: Live Python

Try it — edit the code and click Run!

✅ Check Your Understanding

1. What index is the FIRST item in a list?

2. What does append() do?

3. scores = [10,20,30]. What is scores[2]?