- writelines() is a python file function which are used to insert a data into the file in muliple lines.
Syntax-
f=open('myfile.txt','w')
f.writelines(string)
program-
#write data into file in multiple lines
f=open('myfile.txt','w')
f.writelines("first linensecond linenthird linenfourth linenfifth line")
f.close()
#read the file
f=open('myfile.txt','r')
s=f.read()
print(s)
f.close()
first line
second line
third line
fourth line
fifth line