How to display the contents of text file in reverse order?
Answer / Mr Sonu Kumar
By reading the file line by line, reversing the list of lines, and then joining them back together with n. Here's an example: 'with open("filename", "r") as f:nlines = f.readlines()[::-1]nfor line in lines:n print(line)', replacing "filename" with your file name.
| Is This Answer Correct ? | 0 Yes | 0 No |
Is python interpreted or compiled?
How will you change case for all letters in string in python?
how do you debug a program in python?
With python, how do you find out which directory you are currently in?
Why is python not fully object oriented?
What is s in python 3?
What does defined by whitespace in python?
When should you use the “break” in python?
What are python scripts?
What is a sympy?
How to delete a file in python?
What is difference between range and arange function in python?