python - AttributeError: 'str' object has no attribute ...
www.daniweb.com › programming › software-developmentthis is the error I'm getting for the code below: Error: 'str' object has no attribute 'insert'. filetolist = FileReadToList("test.txt") print filetolist[0] def FileCountLines(s_filename): f = open(s_filename) filestring = f.read() count = operator.countOf(filestring, " ") file.close(f) return count def FileReadToList(s_filename): f = open(s_filename) count = FileCountLines(s_filename) filestring = f.read() filestring.insert(0,count) file.close(f) return filestring.