[' '' '' '' '' '' 'ifafter your changesyou need to convert back to string ( to write to file)use the string join method to "implodethe list back into strings 'join(ls 'spaxxythe join method may look bit backward at first sight because it is method of strings (not of lists)it is called through the desired delimiter join puts the strings in list (or other iterabletogetherwith the delimiter between list itemsin this caseit uses an empty string delimiter to convert from list back to string more generallyany string delimiter and iterable of strings will do'spamjoin(['eggs''sausage''ham''toast']'eggsspamsausagespamhamspamtoastin factjoining substrings all at once might often run faster than concatenating them individually be sure to also see the earlier note about the mutable bytearray string available as of python and described fully in because it may be changed in placeit offers an alternative to this list/join combination for some kinds of -bit text that must be changed often string method examplesparsing text another common role for string methods is as simple form of text parsing--that isanalyzing structure and extracting substrings to extract substrings at fixed offsetswe can employ slicing techniquesline 'aaa bbb ccccol line[ : col line[ :col 'aaacol 'cccherethe columns of data appear at fixed offsets and so may be sliced out of the original string this technique passes for parsingas long as the components of your data have fixed positions if instead some sort of delimiter separates the datayou can pull out its components by splitting this will work even if the data may show up at arbitrary positions within the stringline 'aaa bbb ccccols line split(cols ['aaa''bbb''ccc'the string split method chops up string into list of substringsaround delimiter string we didn' pass delimiter in the prior exampleso it defaults to whitespace-string methods