1) What do I need to do?
π― Your mission: Inventory manager
Start with inventory = ["shield", "rope"].
Add "laser", remove "rope", sort it, then print it.
2) What do I need to know?
List powers
.append(x) adds x to the end
.remove(x) takes x out
.pop() removes the last item (and gives it to you)
.sort() puts the list in order (A-Z or smallest first)
x in list asks: is x in the list? (True/False)
π§° Your toolkit for this mission
Everything you need to know to finish this lesson on your own:
.append(x)
Adds x to the end of the list.
How to write it: Put a dot after the list name.
inventory.append("laser").remove(x)
Takes the item x out of the list.
How to write it: The item must be spelled exactly as in the list.
inventory.remove("rope").sort()
Puts the list in order (A to Z, or smallest first).
How to write it: Empty brackets. It changes the list itself.
inventory.sort() print(inventory)
Empty list + loop
Start with nothing and fill it up.
How to write it: team = [], then append inside a loop.
team = []
for i in range(3):
team.append(input("Hero name? "))
print(team)Think about it
Look at this code. What happens next, and why? Say it in your own words.
bag = ["Rope", "Cape", "Map"] bag.sort()
Watch & explore βΆ
Power-up: List powers
See it happen
1 / 3bag = ["Rope"]
bag.append("Map")append adds an item to the end.
3) Run the code & terminal output
Press βΆ RUN and your program's messages appear here!


Captain Py
Our next adventure is yours to create.
