Build a function that adds an item to a shopping cart. add_item(item, cart) puts item into cart and returns that cart. When cart is not given, it starts a new cart. Complete add_item. Example add_item("pencil", ["notebook"]) → ["notebook", "pencil"] add_item("milk") → ["milk"] (called without cart → a new cart)
Complete a function that adds an item to a shopping cart in Python using the standard library only. It puts the item into the cart and returns that cart, and starts a new list when no cart is given. You practice verifying that the function behaves as intended every time it is called.
When you give a parameter a default so callers can omit the argument, it matters to understand clearly how that default behaves across calls. Calling once can look fine, so the habit of calling the same function without an argument several times and confirming the calls don't affect each other is the key. This problem deals with the area of how default values of a function parameter behave across calls.