Solution 1

def get_second_to_last_elem(list_of_stuff):
    return list_of_stuff[-2]

Get Second to Last Element

Using indexes to count forwards in lists is cool, but going in reverse has style.

Complete the get_second_to_last_elem function so it always returns the second to last element from the end of the list.

Test Cases

test second to last elem - Run Test

def test_second_to_last_elem():
    assert get_second_to_last_elem([1, 2, 3, 4, 5, 6, 7, 8, 'MEMEMEMEMEEEE', 9]) == 'MEMEMEMEMEEEE'
def get_second_to_last_elem(list_of_stuff): pass