How to replace a specific line or a string with another string on a text file with Python? I tried this method:
with open("textfile.txt","r") as f:
newline = []
for word in f.readlines():
newline.append(word.replace("previous_line","new_line"))