To display the contents of a file in reverse, the following code can be used:
1 2 | for line in reversed(list(open(filename.txt))): print(line.rstrip()) |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.