you to read and write to the file (' +'if you omit the mode argumentpython opens the file in read-only mode by default the open(function automatically creates the file you're writing to if it doesn' already exist howeverbe careful opening file in write mode (' 'because if the file does existpython will erase the file before returning the file object at we use the write(method on the file object to write string to the file this program has no terminal outputbut if you open the file programming txtyou'll see one lineprogramming txt love programming this file behaves like any other file on your computer you can open itwrite new text in itcopy from itpaste to itand so forth note python can only write strings to text file if you want to store numerical data in text fileyou'll have to convert the data to string format first using the str(function writing multiple lines the write(function doesn' add any newlines to the text you write so if you write more than one line without including newline charactersyour file may not look the way you want it tofilename 'programming txtwith open(filename' 'as file_objectfile_object write(" love programming "file_object write(" love creating new games "if you open programming txtyou'll see the two lines squished togetheri love programming love creating new games including newlines in your write(statements makes each string appear on its own linefilename 'programming txtwith open(filename' 'as file_objectfile_object write(" love programming \ "file_object write(" love creating new games \ "the output now appears on separate linesi love programming love creating new games