Question: import pickle from inventory _ item import InventoryItem, CATEGORY _ LIST def main ( ) : inventory = load _ inventory ( ) display _
import pickle
from inventoryitem import InventoryItem, CATEGORYLIST
def main:
inventory loadinventory
displayinventoryinventory
answer
while answer.lowern:
# TODO Create an InventoryItem object, ask the user for item input
# using the object's method, then append the object to the inventory
# list.
answer inputDo you want to enter more items?
for category in CATEGORYLIST:
displaycategorycategory inventory
displayinventoryinventory
saveinventoryinventory
def loadinventory:
inventory
# TODO Attempt to load inventory data from a binary file named
# inventory.dat. If the file exists, load it into the inventory list.
# If the file does not exist, leave the inventory list empty.
return inventory
def saveinventoryinventory:
# TODO Open a binary file named inventory.dat and dump the inventory
# list that has been passed in as a parameter to that file.
printInventory was saved in inventory.dat.
def displaycategorycategoryname, inventory:
print
header f'Items in categoryname
divider lenheader
printheader
printdivider
# TODO Display inventory items that are in the specific category
# Both the category name and inventory are passed in as parameters.
# If there are no items in the category, print No items."
def displayinventoryinventory:
print
printCurrent Inventory'
print
# TODO Display the inventory items that are in the inventory list
# that was passed in as a parameter. If the list is empty, display
# "Inventory is empty."
print
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
