Created
August 17, 2022 20:36
-
-
Save Liam-Nothing/9c9125309de0be0d50ef3105ed2889c1 to your computer and use it in GitHub Desktop.
Reverse lines in text file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = open("text.txt", "r") | |
s = f.read() | |
s = s.split("\n") | |
s.reverse() | |
s = "\n".join(s) | |
f.close() | |
f = open("reverse_text.txt", "w") | |
f.write(s) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment