Is there a way to do this? Say I have a file that's a list of names that goes like this:
This is a way of doing the trick.
f = open("path_to_file", "r") contents = f.readlines() f.close() contents.insert(index, value) f = open("path_to_file", "w") contents = "".join(contents) f.write(contents) f.close()
"index" and "value" are the line and value of your choice, lines starting from 0.