add_item(item, cart=[]) is buggy: because the default list is created once and shared across calls, items from previous calls leak into later ones. Rewrite add_item so each call with no cart argument starts from a fresh empty list, while still allowing a caller to pass in and extend their own list. Return the resulting list.add_item("apple")
add_item("banana")['apple'], ['banana']
Each call without a cart argument must produce an independent list, not accumulate across calls.
add_item("milk", ["bread"])['bread', 'milk']
When a cart is supplied, the item is appended to it.
Use None as the default sentinel value, then create a new list inside the function body when cart is None.
Remember to append item before returning.