Exercise 10: Two Channels and a Countdown — Possible Solution ==================================================================== import sys import time tasks = [("backup", True), ("upload", False), ("cleanup", True)] failures = 0 for name, succeeded in tasks: if succeeded: print(f"OK: {name}", flush=True) else: print(f"FAILED: {name}", file=sys.stderr, flush=True) failures += 1 print(f"{len(tasks) - failures} of {len(tasks)} tasks succeeded", flush=True) for n in (3, 2, 1): print(n, end=" ", flush=True) time.sleep(0.2) print("Go!") Output: OK: backup FAILED: upload OK: cleanup 2 of 3 tasks succeeded 3 2 1 Go! WHY THIS WORKS AS AN ANSWER ------------------------------ file=sys.stderr sends a line to the error channel instead of the normal one. In a terminal both appear on screen, but a program can redirect them separately, for example saving normal output to a file while errors still show on the screen. flush=True writes each line out immediately; without it normal output is held in a buffer and can appear after later error lines when the two are redirected together. The countdown uses end=' ' to stay on one line, and flush=True is essential there: without it the numbers could sit in the buffer and all appear together at the end rather than one every fraction of a second. The final bare-argument print('Go!') supplies the newline.