Python’s os module lets a program ask the operating system about files. In an order program, it checks whether the saved orders file exists before deciding whether to load it or start with an empty list. section 9.0
Checking for saved orders
Import os, then call os.path.exists(filename). It returns True when the file exists and False otherwise, allowing load_orders() to read existing JSON data or return []. section 9.0 section 9.1
Use os in a file-loading workflow:
- Import the module with import os. section 9.0
- Check the filename with os.path.exists(filename). section 9.1
- Load existing data or create an empty list when the file is missing. section 9.0




