Add-to-cart helper

Python · FastAPI · beginner · greenfield

Adds the cart helper: appends the item and returns the cart, defaulting to a fresh empty cart when none is passed. Verified by adding a couple of items.

Requirements

Files touched

--- app/cart.py
+def add_item(name: str, cart: list[str] = []) -> list[str]:
+    cart.append(name)
+    return cart

Review this PR

Python practice