- learning pythonopen blank file in your text editor and write few lines summarizing what you've learned about python so far start each line with the phrase in python you can save the file as learning_python txt in the same directory as your exercises from this write program that reads the file and prints what you wrote three times print the contents once by reading in the entire fileonce by looping over the file objectand once by storing the lines in list and then working with them outside the with block - learning cyou can use the replace(method to replace any word in string with different word here' quick example showing how to replace 'dogwith 'catin sentencemessage " really like dogs message replace('dog''cat'' really like cats read in each line from the file you just createdlearning_python txtand replace the word python with the name of another languagesuch as print each modified line to the screen writing to file one of the simplest ways to save data is to write it to file when you write text to filethe output will still be available after you close the terminal containing your program' output you can examine output after program finishes runningand you can share the output files with others as well you can also write programs that read the text back into memory and work with it again later writing to an empty file to write text to fileyou need to call open(with second argument telling python that you want to write to the file to see how this workslet' write simple message and store it in file instead of printing it to the screenwrite_ message py filename 'programming txtu with open(filename' 'as file_objectv file_object write(" love programming "the call to open(in this example has two arguments the first argument is still the name of the file we want to open the second argument' 'tells python that we want to open the file in write mode you can open file files and exceptions