Loading…
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!
Create a list numbers = [10, 20, 30, 40, 50] and print the third element (30).
Downloading Python… (one-time, ~10 MB)
This runs entirely in your browser and is cached for next time.