Getting code to run is only half of an assignment. The other half is proving that the code satisfies every requirement in the specification. Missing requirements like "write output to a file" are usually not a coding problem — it is a reading and verification problem.

Why this happens

  • You focus on the technical challenge and treat the instructions as background noise.
  • Requirements live in short-term memory and get pushed out while debugging.
  • You stop as soon as the script "works," before checking deliverables.

A repeatable workflow

  1. Read the requirements aloud, one at a time. Do not skim.
  2. Convert each requirement into a checklist item. For example: □ output written to results.txt.
  3. Decide output file names and formats before writing logic. Hardcode them or accept them as CLI arguments. For pipeline-ready scripts, see Designing Python Scripts for Automation and Pipelines.
  4. Write output handling first. Open the file and decide what will be written. Then implement the analysis. Common pitfalls when writing files are covered in Python File Handling Pitfalls Cheat Sheet.
  5. Run and verify. After the script runs, inspect the output file: cat results.txt, ls -l results.txt, or open it in an editor.
  6. Check every box. If a requirement is unchecked, the assignment is not done.

Example

import sys

input_path = "data.bin"
output_path = "output.txt"

with open(input_path, "rb") as f:
    data = f.read()

result = f"Read {len(data)} bytes from {input_path}\n"

with open(output_path, "w") as f:
    f.write(result)

print(f"Done. Wrote {output_path}")

In security work

This habit separates "I can code" from "I can deliver."