# Print to the text file file = open('log.txt', 'w') print('This is a sample print statement', file = file) print('Hello World', file = file) file.close()