How to read a file in reverse order using python? I want to read a file from last line to first line.
Read the file line by line and then add it on a list in reverse order.
Here is an example of code :
reverse = [] with open("file.txt", "r") as file: for line in file: line = line.strip() reverse[0:0] = line