← All missions

πŸŽ’ The Hero Backpack

πŸŽ’ Organizing Stuff with Lists

1) What do I need to do?

🎯 Your mission: Pack for the mission

Make 3 lists:

team with 3 hero names β€’ scores with 3 numbers β€’ inventory with at least 2 gadgets

Print all three.

2) What do I need to know?

A list holds lots of things

A variable holds one thing. A list holds many things, in order!

Lists use square brackets [ ] with commas between items.

Lists can hold strings, numbers, or both. An empty list is just [].

🧰 Your toolkit for this mission

Everything you need to know to finish this lesson on your own:

List

One variable that holds many values, in order.

How to write it: Square brackets [ ], items separated by commas.

team = ["Blaze", "Storm", "Zip"]

Lists of numbers

Numbers go in without quotes.

How to write it: [10, 20, 30]

scores = [10, 20, 30]

Printing a list

Shows the whole list with its brackets.

How to write it: print(team)

inventory = ["shield", "rope"]
print(inventory)

len()

Counts how many items are in a list.

How to write it: len(team)

print(len(team))  # 3

Think about it

Look at this code. What happens next, and why? Say it in your own words.

things = ["Nova", 10, 1.4]
Watch & explore β–Ά

Power-up: A list holds lots of things

See it happen

1 / 3
bag = ["Rope", "Map", "Cape"]
Rope
Map
Cape

A list is one container with several items, separated by commas.

3) Run the code & terminal output

Code Lab 🐍Playground β€” experiment freely!
Hero Terminal

Press β–Ά RUN and your program's messages appear here!

Equipment Vault
Equipment Vault
Your superhero companion

Captain Py

Our next adventure is yours to create.