Python Programming - Reading and Writing Files - Discussion

Discussion Forum : Reading and Writing Files - General Questions (Q.No. 26)
26.
How can you append the string "new content" to an existing file named "existing_file.txt"?
open("existing_file.txt", "a").write("new content")
open("existing_file.txt", "w").write("new content")
append_content("existing_file.txt", "new content")
with open("existing_file.txt", "a") as file:
    file.append("new content")
Answer: Option
Explanation:
The mode "a" in open() is used for appending content to an existing file.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.