+ 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.

5th May 2019, 10:50 PM
Kittyky.n
Kittyky.n - avatar
3 odpowiedzi
+ 1
Try this normal = open('moths.txt', 'r').read(); reversedText = open('monthsRev.txt', 'w') reversedMonths = normal[::-1] for moth in reversedMonths: reversedText.write(month)
6th May 2019, 4:44 AM
Dlite
Dlite - avatar
0
What do you need help with?
6th May 2019, 4:18 AM
Dlite
Dlite - avatar
0
I need help with reversing the list properly
6th May 2019, 4:26 AM
Kittyky.n
Kittyky.n - avatar