Google News
logo
Python - Interview Questions
Write a code to display the contents of a file in reverse.
To display the contents of a file in reverse, the following code can be used:
 
for line in reversed(list(open(filename.txt))):
print(line.rstrip())
Advertisement