read(method returns the string that is stored in the file alternativelyyou can use the readlines(method to get list of string values from the fileone string for each line of text for examplecreate file named sonnet txt in the same directory as hello txt and write the following text in itwhenin disgrace with fortune and men' eyesi all alone beweep my outcast stateand trouble deaf heaven with my bootless criesand look upon myself and curse my fatemake sure to separate the four lines with line breaks then enter the following into the interactive shellsonnetfile open(path home('sonnet txt'sonnetfile readlines([whenin disgrace with fortune and men' eyes,\ ' all alone beweep my outcast state,\ 'and trouble deaf heaven with my bootless cries,\ 'and look upon myself and curse my fate,'note thatexcept for the last line of the fileeach of the string values ends with newline character \ list of strings is often easier to work with than single large string value writing to files python allows you to write content to file in way similar to how the print(function "writesstrings to the screen you can' write to file you've opened in read modethough insteadyou need to open it in "write plaintextmode or "append plaintextmodeor write mode and append mode for short write mode will overwrite the existing file and start from scratchjust like when you overwrite variable' value with new value pass 'was the second argument to open(to open the file in write mode append modeon the other handwill append text to the end of the existing file you can think of this as appending to list in variablerather than overwriting the variable altogether pass 'aas the second argument to open(to open the file in append mode if the filename passed to open(does not existboth write and append mode will create newblank file after reading or writing filecall the close(method before opening the file again let' put these concepts together enter the following into the interactive shellbaconfile open('bacon txt'' 'baconfile write('helloworld!\ ' baconfile close(baconfile open('bacon txt'' 'baconfile write('bacon is not vegetable '