Cart with methods add(name, price), remove(name) (silently ignoring unknown names), and total(). Items live in an internal dict of name → price; adding the same name twice overwrites the price.c = Cart(); c.add('pen', 10); c.add('book', 250); c.remove('pen'); c.total()250
Only the book remains.
A dict keyed by name keeps it simple.
dict.pop(name, None) removes safely.