Skip to content
dreamcode
dreamcode
Map
Lists
Lesson 26 of 77
+15 XP on finish
PYTHON BASICSChapter 5 · Collections

Lists of things

A list keeps multiple values together. Write square brackets with commas in between. Access individual items with square brackets and their index (position), starting at 0.

Worked example

How it reads

  • ["wispy", "puffy"] creates a list with two text items.
  • clouds[1] looks up the item at position 1 (the second item).
  • len(clouds) counts the total items in the list, here 2.
Cloud tip: Indexes start at 0. So the first item is clouds[0], and the second is clouds[1].
main.py
PYTHON
real Python, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Print the last cloud using a negative index, then print how many clouds there are. The output should end with stratus and 3.

Press Run to check your work.