Question: %%% Python Jupiter Notepad %% # Your starting inventory inventory = {'gold': 150, 'pouch' : ['flint', 'twine', 'lucky charm'], 'backpack' : ['knife', 'bedroll', 'jerky']} #
%%% Python Jupiter Notepad %%
# Your starting inventory inventory = {'gold': 150, 'pouch' : ['flint', 'twine', 'lucky charm'], 'backpack' : ['knife', 'bedroll', 'jerky']}
# TODO: Your code goes here

Q6. (4 pts) Tracking inventory with a dictionary You are going on an adventure and will take a number of objects with you. They will be represented using a dictionary and lists. Starting with the initial dictionary here, write the Python statement for each step below. Create a complete Python program with the initial dictionary and all of your steps. You are starting with these initial items in your inventory: inventory -'gold': 150, , 'twine', 'lucky charm'1, 'backpack' : ['knife, 'bedroll', 'jerky' 1 Write the code for each of the following steps: 1. Add a key for a 'pocket 2. Put in your 'pocket' the values 'pebble', 'large chestnut', and 'lint 3. Sort the items in your backback. 4. Don't like jerky? Remove it and add some 'crackers 5. You found 25 gold. Add that to the 'gold key 6. Print the final state of the dictionary and confirm that it has the following elements (not necessarily in the same order, of course) Output should look similar to this: inventory= {'gold': 175, pouch : ['flint', 'twine, 'lucky charm', 'backpack' : ['bedroll', "crackers', 'knife', pocket' 'pebble, 'large chestnut', 'lint'1) Remember because this is a dictionary your order of gold, pouch, backpack, and pocket may vary In [ ]: # Your starting Inventory inventory-gold 150, pouch' : ['flint'twine',lucky charm', backpack' : ['knife', "bedroll', "jerky']} # TODO: Your code goes here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
