I need to return the last k numbers of a list in Python without importing any new libraries
list1=[1,2,3,4,5,6,7]
def example(list1,k)
return ???
I need to return the last (k) numbers of list1. For example if (k) is 2 then the function will return [6,7] Another example if (k) is 4 then it returns [4,5,6,7]
do you have any advice to accomplish this? thanks