Spaces:
Sleeping
Sleeping
Download cart.py from Rammohan0504/First-Project: direct link, hf CLI and curl.
- Browser
- Download file 312 Bytes
-
https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/cart.py
- Command line
-
hf download hf://spaces/Rammohan0504/First-Project/cart.py
-
curl -L -o cart.py https://huggingface.co/spaces/Rammohan0504/First-Project/resolve/main/cart.py
312 Bytes
| class Cart: | |
| def __init__(self): | |
| self.items = [] | |
| def add_item(self, item): | |
| self.items.append(item) | |
| return f"Added {item['name']} to the cart." | |
| def view_cart(self): | |
| return self.items | |
| def total_price(self): | |
| return sum(item["price"] for item in self.items) | |