files the write method of the file handle object puts data into the filereturning the number of characters written the default write mode is text for writing (and readingstrings line "this here' the wattle,\nfout write(line againthe file object keeps track of where it isso if you call write againit adds the new data to the end we must make sure to manage the ends of lines as we write to the file by explicitly inserting the newline character when we want to end line the print statement automatically appends newlinebut the write method does not add the newline automatically line 'the emblem of our land \nfout write(line when you are done writingyou have to close the file to make sure that the last bit of data is physically written to the disk so it will not be lost if the power goes off fout close(we could close the files which we open for read as wellbut we can be little sloppy if we are only opening few files since python makes sure that all open files are closed when the program ends when we are writing fileswe want to explicitly close the files so as to leave nothing to chance debugging when you are reading and writing filesyou might run into problems with whitespace these errors can be hard to debug because spacestabsand newlines are normally invisibles ' \ \ print( the built-in function repr can help it takes any object as an argument and returns string representation of the object for stringsit represents whitespace characters with backslash sequencesprint(repr( )' \ \