10/19 Answer


I have tried and tried to find the solution, but this objective is broken. Will someone tell me a working code?

class ShoppingCart(object):
"""Creates shopping cart objects
for users of our fine website."""
items_in_cart = {}
def init(self, customer_name):
self.customer_name = customer_name

def add_item(self, product, price):
    """Add product to the cart."""
    if not product in self.items_in_cart:
        self.items_in_cart[product] = price
        print product + " added."
        print product + " is already in the cart."

def remove_item(self, product):
    """Remove product from the cart."""
    if product in self.items_in_cart:
        del self.items_in_cart[product]
        print product + " removed."
        print product + " is not in the cart."
my_cart = ShoppingCart("Elvis")
my_cart.add_item("banjo", 10)


Hi @arccoder85174 ,

Your code is not fully formatted, so we cannot be certain about what lines are indented. The add_item and remove_item methods need to be indented, including their headers, otherwise they are not part of the ShoppingCart class definition.


Yes, it is indented properly.