DSatishchandra's picture
Create cart.py
b65065d verified
raw
history blame
316 Bytes
cart = []
def add_to_cart(name, price):
global cart
cart.append({"Name": name, "Price": price, "Quantity": 1})
return cart
def view_cart():
global cart
total = sum(float(item["Price"]) * item["Quantity"] for item in cart)
return cart, total
def clear_cart():
global cart
cart = []