I need to be able to reverse a whole file, or at least the contents of it. My code so far is:
def reverse_file(of, rf):
oldfile = open(of, 'r')
reversefile = open(rf, 'w')
filedata = oldfile.read()
rdata = str_reverse(filedata)
reversefile.write(rdata)
oldfile.close()
reversefile.close()
The problem is I need to define str_reverse
and I'm not sure how to create a function that reverses everything. Any help?