It's Not All Animals and Fruits


#1
Not sure how to complete this exercise. The name of is It's not all animals and fruits. Can someone please explain or assist me with this exercise?


 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
    my_cart = ShoppingCart("Bananas")
def add_item(self, product, price):
    """Add product to the cart."""
    mycart.add_item("expensive",20)
    if not product in self.items_in_cart:
        self.items_in_cart[product] = price
        print product + " added."
    else:
        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."
    else:
        print product + " is not in the cart."

"""This is what is asked"""

Create an instance of ShoppingCart called my_cart. Initialize it with any values you like, then use the add_item method to add an item to your cart.


#2

its fine to revisit exercises if you forgot what a class instance is:

https://www.codecademy.com/en/courses/python-intermediate-en-WL8e4/0/5


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.