Day 7
Objective: Manage your utility belt with Python Lists!
OPEN GOOGLE COLAB(Click to open in a new tab)
Every superhero needs to keep track of their gadgets. Batman has his utility belt, and Wonder Woman has her Lasso of Truth. But they carry MANY items!
Instead of making a variable like gadget1, gadget2, gadget3... we
can use a LIST!
Lists are like a backpack where you can store multiple things. Use square brackets [].
Computers start counting at 0! To get the FIRST item, we ask for index
0.
Found a new gadget? Use .append() to add it to the end!
Lost something or used it up? Use .remove() to take it out.
1. Create Your Belt:
gadgets with at least 3 gadgets inside
(Strings).2. Check the First Item:
0.3. Add New Gear:
.append() to add a "Grappling Hook" (or any new item) to your list.4. Use a Gadget:
.remove() to delete one item that you "used".Lists use SQUARE brackets [].
Functions use PARENTHESES ().
Don't mix them up!
Paste your Python code here to check if your inventory system works! (Type it out, no pasting!)
[].
[0] (or other index).
.append() to add an item.
.remove() to delete an item.
This certifies that
Has mastered the
Superhero Inventory System!
Python Path - Day 7