Question:medium

Differentiate between 'w' and 'a' file modes in Python.

Show Hint

Updated On: Jan 13, 2026
Show Solution

Solution and Explanation

\[ \begin{array}{|c|c|} \hline \textbf{File Mode} & \textbf{Description} \\ \hline 'w' & Opens the file for writing. Existing content is erased. \\ 'a' & Opens the file for appending. Data is added to the end. \\ \hline \end{array} \]

Was this answer helpful?
0