`list.append(item)` adds one item to the end of a Python list. Start with an empty list, then append items as they arrive. The list keeps them in the order you add them. section 8.0
Collecting customer orders
Make an empty `orders` list, then add each order dictionary one at a time: `orders = []` `orders.append(order)` `orders.append(order1)` Afterward, `orders` can be saved as JSON instead of saving only one order. section 8.0
`append()` is especially handy when the final number of items is not known ahead of time. A menu can build its allowed responses by looping from `1` through the menu length, converting each number to text, and appending it to a list. section 4.0
orders.append(order) orders.append(order1)
This short listing shows two dictionaries being added to the same empty list, one append call at a time. section 8.0
Saving confirmed orders
Keep one shared list while a program serves customers. When a customer confirms an order, use `orders.append(order)`. Later, save the whole list with `json.dump(orders, f, indent=4)`. Orders canceled or left unfinished do not need to be appended. section 9.0 section 9.0
A simple append routine is:
- Create the list: `items = []`. section 8.0
- Obtain or create the next item. section 9.0
- Add it: `items.append(item)`. section 8.0
- Use the growing list, such as by checking allowed answers or saving orders. section 4.0 section 8.0
