Question: import pickle from inventory _ item import InventoryItem, CATEGORY _ LIST def main ( ) : inventory = load _ inventory ( ) display _

import pickle
from inventory_item import InventoryItem, CATEGORY_LIST
def main():
inventory = load_inventory()
display_inventory(inventory)
answer =''
while answer.lower()!='n':
# 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 = input('Do you want to enter more items? ')
for category in CATEGORY_LIST:
display_category(category, inventory)
display_inventory(inventory)
save_inventory(inventory)
def load_inventory():
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 save_inventory(inventory):
# TODO - Open a binary file named inventory.dat and dump the inventory
# list that has been passed in as a parameter to that file.
print('Inventory was saved in inventory.dat.')
def display_category(category_name, inventory):
print()
header = f'Items in {category_name}'
divider = len(header)*'-'
print(header)
print(divider)
# 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 display_inventory(inventory):
print()
print('Current 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!