Question:

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

Answer:

1. convert the given file into a list.
2. reverse the list by using reversed()
Eg: for line in reversed(list(open(“file-name”,”r”))):
print(line)


Keywords:

© 2017 QuizBucket.org