The following is a simple solution to the problem of defining a function to find the last element of a list. Note that you do not need to write a single line of code to make the doctest work.
>>> def last(some_list): ... return some_list[-1] >>> >>> a_list = [0, 1, 2, 3, 4, 5, 6, 7] >>> last(a_list) 7 >>> another_list = ['a', 'b', 'c', 'd', 'e', 'f'] >>> last(another_list) 'f'