The None-Sentinel Fix

def add_item(item, cart=None):
    cart = cart if cart is not None else []
    cart.append(item)
    return cart

print(add_item("apple"))
print(add_item("banana"))
What does the second print show, and why does this version avoid the bug from cart=[]?

A

['apple'] followed by a TypeError, since None has no .append method

B

['banana']. None is the (immutable) default, and a fresh list is built inside the body on every call where cart wasn't supplied

C

['apple', 'banana'], for the same reason as the cart=[] version: the default object still accumulates state across calls

D

['banana'], because None forces Python to re-evaluate the entire default expression cart=None fresh on every call