Challenge 1
Enter the opened file through the ExitStack so it is closed when the stack exits.
from contextlib import ExitStack
from pathlib import Path
from tempfile import TemporaryDirectory
with TemporaryDirectory() as directory:
path = Path(directory) / "note.txt"
path.write_text("ready", encoding="utf-8")
with ExitStack() as stack:
file =
print(file.read())
Press Ctrl⌘Enter to check your answer