Advertisements
Advertisements
Question
Explain the use of output function writelines() with an example.
Code Writing
Explain
Advertisements
Solution
writelines(): Writes a sequence of strings. Newline characters must be supplied by the programmer.
lines = ["First line\n", "Second line\n"]
with open("data.txt", "w") as file:
file.writelines(lines)shaalaa.com
Is there an error in this question or solution?
