Python

Creating and Accessing Lists

Lists

Lists store multiple items in a single variable.

fruits = ["apple", "banana", "cherry"]
print(fruits[0])  # apple (first item)
print(fruits[-1]) # cherry (last item)
print(len(fruits)) # 3 (length)

Index starts at 0!

Your Task

Create a list numbers = [10, 20, 30, 40, 50] and print the third element (30).

script.py
Loading PYTHON engine...
Downloading Python… (one-time, ~10 MB)

Downloading Python… (one-time, ~10 MB)

This runs entirely in your browser and is cached for next time.