CBSE Class 12 Computer Science
Question 95 of 136
Data File Handling — Question 34
Back to all questionsdef write_to_file(file_path):
lines_to_write = ["The sun sets over the horizon.", "Birds chirp in the morning.", "Raindrops patter on the roof.", "Leaves rustle in the breeze."]
with open(file_path, "w") as file:
for line in lines_to_write:
file.write(line + '\n')
write_to_file("mylife.txt")