Oops, try again. list_extender([1, 2, 3, 4]) returned [1, 2, 3, 4] instead of [1, 2, 3, 4, 9]


#1



https://www.codecademy.com/en/courses/python-beginner-nzzVa/2/4?curriculum_id=4f89dab3d788890003000096


Oops, try again. list_extender([1, 2, 3, 4]) returned [1, 2, 3, 4] instead of [1, 2, 3, 4, 9]


I am trying to append 9 to list n, but I keep getting this error message :confused:


n = [3, 5, 7]
# Add your function here
def list_extender(lst):
    n.append(9)
    return lst
print list_extender(n)


#2

Should be lst.append(9). As lst is your function parameter.

You got the error message because if they used another list such as [1, 2, 3, 4], your function won't be adding the 9 because you seem to be just adding the 9 to a list called n.


#3

Thank you so much! This has solved it.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.