I\'m writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest
Another Solution
if your txt file looks like this: mouse snake cat lizard wolf dog
you could reverse this file by simply using array indexing in python '''
contents=[]
def tail(contents,n):
with open('file.txt') as file:
for i in file.readlines():
contents.append(i)
for i in contents[:n:-1]:
print(i)
tail(contents,-5)
result: dog wolf lizard cat