Q. Write a method in python to write multiple line of text content into a text file mylife.txt line.


Answer =


file = open("mylife.txt", "w")

l = []

while True:
	data = input("Enter the contents otherwise, Enter ""exit"" for stop the program :")
	if data == 'exit':
		break
	else :
		l  = l + [data + '\n']

file.writelines (l)

file.close ()

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post