data = data2 = data3 = ""
with open('pushkin.txt', encoding='utf-8', mode='r') as fp:
data = fp.read()
with open('romeo.txt', encoding='utf-8', mode='r') as fp:
data2 = fp.read()
with open('byron.txt', encoding='utf-8', mode='r') as fp:
data3 = fp.read()
data += "\n"
data += data2 + data3
with open('poems.txt', 'w', encoding='utf-8') as fp:
fp.write(data)
With this code, I have transferred three text files into one. Now I need to turn over text in that file, like this:
ABC CDA
BCA --> BCA
CDA ABC
but I don't know how. I thought using reverse()
or reversed()
, but that makes it just from
abc
to cba