+ 1
Reads file and writes out new file with the lines in reversed order
#opening month text file f = (open("months.txt", "r")) data = f.read() #opening a new month text file lisiting the months in reversed order f1= open("newMonths.txt", "w") newfile = f1.write(data[::-1]) print I need help with reversing them. So far the result is this >>> rebmeced, rebmevon, rebotco, rebmetpes, tsugua, yluj, enuj, yam, lirpa, hcram, yraurbef, yraunaj. But it has to be like this >>> December, November, october, september, august, july, june, may, april, march, february, january.
3 ответов
+ 1
Try this
normal = open('moths.txt', 'r').read();
reversedText = open('monthsRev.txt', 'w')
reversedMonths = normal[::-1]
for moth in reversedMonths:
reversedText.write(month)
0
What do you need help with?
0
I need help with reversing the list properly