Home

Published

- 1 min read

python write to file

img of python write to file

The solution for this is noted below

python write to file

Solution

   file = open(“testfile.txt,”w”) 
 
file.write(“Hello World”) 
file.write(“This is our new text file) 
file.write(and this is another line.) 
file.write(“Why? Because we can.) 
 
file.close()

Try other methods by searching on the site. That is if this doesn’t work