


PYTHON INTERMEDIATE
File handling
Use the with statement and open() function to open files. The context manager automatically closes the file when the block ends.
How it reads
open("sky.txt", "w") opens a file named sky.txt for writing
with ... as f automatically closes the file object

Cloud tip: Always prefer with open(...) to manual file opening to prevent memory leaks.
