I am trying to do something pretty simple: I need to get the last 40 elements from a list.
I noticed that there is no direct way to do so, like you would do in a string, using one of the standard functions to get the last n chars from the string.
I know how to get the the length of the list; so what I had in mind is to just use the max lenght and do a for loop starting from the end of the list, and go backwards for 80 times.
max_size= len(my_list)
for i in range(max_size, (maxsize-80)):
print my_list[i]
i=i-1
Is this the correct way to do so? Or there is some sort of function in the list object that may do this? I tried the documentations of the python site but had no luck.