i want to change the text in the file for example
change all the a's to e
all the e's to a
but my problem is when i do the first step all the a's are changed to e and then later changed back to all a's
the test.txt file contains("this is a message )
so i want to make the changes once
and the result should be (""thi3 i3 e ma33ega"
i hope that the explanation was clear
plz help
def makeChangesToFile():
infile=open("test.txt","r")
contents=infile.read()
infile.close()
tofile=open("newContents.txt","w")
contents=contents.replace("a","e")
contents=contents.replace("e","a")
contents=contents.replace("s","3")
tofile.write(contents)
tofile.close()
makeChangesToFile()

New Topic/Question
Reply



MultiQuote







|