Theory

Lists store multiple values in one variable.

Create a list:
fruits = ["apple", "banana", "orange"]
numbers = [1, 2, 3, 4, 5]

Access items by index (starting from 0):
print(fruits[0]) # apple
print(fruits[1]) # banana

Get list length:
print(len(fruits)) # 3

Add items:
fruits.append("grape")

Loop through list:
for fruit in fruits:
print(fruit)

Exercises in this lesson

Solve in the playground

Frequently asked questions

What is the lesson “Lists” about?

Learn to store multiple items in lists.

How many exercises are in this lesson?

This lesson has 5 exercises.

Do I need to install anything to do the exercises?

No. The code is written and run in the browser.

Next lesson: Functions →