1file = open(“testfile.txt”,”w”)
2
3file.write(“Hello World”)
4file.write(“This is our new text file”)
5file.write(“and this is another line.”)
6file.write(“Why? Because we can.”)
7
8file.close()
1def save_to_file(content, filename):
2 with open(filename, 'w') as file:
3 file.write(content)
4
5import file_operations
6file_operations.save_to_file('my_content', 'data.txt')