Solution 1

def append_elem_to_list(a_list, an_elem):
    return a_list

Fix the Append Operation

The function provided is broken. Your job is to figure out what's going on and fix it.

Use the tests to guide you.

Test Cases

test - Run Test

def test_append():
    list_1 = []
    append_elem_to_list(list_1, 'X')

    assert list_1 == ['X']

    list_2 = [3, 2, 1]
    append_elem_to_list(list_2, 9)

    assert list_2 == [3, 2, 1, 9]
def append_elem_to_list(a_list, an_elem): # THIS IS BROKEN # YOUR JOB IS TO FIX IT # You can change this function as much as you want a_list.add(an_elem) return a_list