Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to display the contents of text file in reverse order?



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

Post New Answer

More Python Interview Questions

Is python interpreted or compiled?

1 Answers  


How will you change case for all letters in string in python?

1 Answers  


how do you debug a program in python?

1 Answers  


With python, how do you find out which directory you are currently in?

1 Answers  


Why is python not fully object oriented?

1 Answers  


What is s in python 3?

1 Answers  


What does defined by whitespace in python?

1 Answers  


When should you use the “break” in python?

1 Answers  


What are python scripts?

1 Answers  


What is a sympy?

1 Answers  


How to delete a file in python?

1 Answers  


What is difference between range and arange function in python?

1 Answers  


Categories