Question: (a) [25 marks] Write a function named add_item that takes the inventory dictionary as its parameter. This function will ask the user to enter the
(a) [25 marks] Write a function named add_item that takes the inventory dictionary as its parameter. This function will ask the user to enter the name of an item. If the item is in the inventory, the user will be asked to enter the number of this item to add to the inventory. If the item is not in the inventory, the user will be asked for a price for the item as well has the number of items to add to the inventory. The price and count will be keys to a dictionary that comprise the value for the item, e.g., {"Banana": {"price": 1.99, "count": 15}}. The value for the key "price" is a float, and the value for the key "count" is an int. Error checking must be implemented to ensure that an empty string is not entered for the name of the item and that "price" and count are float and int types, respectively. When an item is added to the inventory, the first letter will be capitalized, and a success message will be displayed. This function returns None.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
