class ShoppingCart:
def __init__(self):
self.items = []
def add_item(self, name, price):
self.items.append({"name": name, "price": price})
def remove_item(self, name):
self.items = [item for item in self.items if item["name"] != name]
def get_total(self):
return sum(item["price"] for item in self.items)
cart = ShoppingCart()
cart.add_item("파이썬 입문", 20000)
cart.add_item("데이터 분석", 30000)
print(cart.get_total())
cart.remove_item("파이썬 입문")
print(cart.get_total())
To embed this project on your website, copy the following code and paste it into your website's HTML: