file text replacement | Sololearn: Learn to code for FREE!


file text replacement

is it possible to access a .txt file and replace all "t" with "a" with open('file.txt', 'r') as f: with open('file.txt', 'w') as w: for t in if "t" in t: w.write("a")

11/27/2021 11:59:21 PM


1 Answer

New Answer


- read the text - change the text (e.g. using .replace()) - save the text