Skip to content

Instantly share code, notes, and snippets.

@Liam-Nothing
Created August 17, 2022 20:36
Show Gist options
  • Save Liam-Nothing/9c9125309de0be0d50ef3105ed2889c1 to your computer and use it in GitHub Desktop.
Save Liam-Nothing/9c9125309de0be0d50ef3105ed2889c1 to your computer and use it in GitHub Desktop.
Reverse lines in text file
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