python_test / models /cart.py
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 = []