115. Python Program to Remove an Item from a Shopping Cart
MediumChange items
Overview
Remove a pair from a dictionary and use the value you took out.
Problem Statement
The cart is already in the starter code. Each key is an item and each value is how many of it are in the cart:
cart = {"apple": 3, "bread": 1, "milk": 2}
Read the name of an item. If it's in the cart, remove it and print Removed, the quantity and the item, like Removed 1 bread. If it isn't, print the item and is not in the cart, like eggs is not in the cart. In both cases, then print Items left: with the number of pairs left, and finally the cart. For example, for bread:
Removed 1 bread
Items left: 2
{'apple': 3, 'milk': 2}
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One value per line, in this order. Example:
bread
Output
The output for that example:
Removed 1 bread
Items left: 2
{'apple': 3, 'milk': 2}
The tests try 3 different inputs.