Why is the with statement recommended when working with files in Python?
Correct answer
C. It closes the file automatically
C. It closes the file automatically
The context manager ensures the file is closed even if an error occurs.
Asked in: Python Interview File Handling
https://docs.python.org/3/tutorial/inputoutput.htmlNot sure why the answer is C? Ask here and get an explanation.