Here's how you write to a file with Python.
Let's say we have a string, myString, the contents of which we want to write to a file.
myString = "I am going to write this string to a file with Python"
To write myString to a file, we first need to specify the file we want to write to, like so:
file = open('string.txt', 'w')
Then we use the write function (which is a built-in function) to write the string to the file:
And that's it!
f = open( 'article.txt', 'w')