List manipulation in functions - Confusing Error


#1

My code is:


n = [3, 5, 7]
def list_extender(lst):
    n.append(9)
    return n



print list_extender(n)

When I submit it, I get the following error:

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

Why would the list contain 1, 2, and 4 when I didn't append those numbers? Shouldn't it return [3, 5, 7, 9]?


#2

HI this part of the instruction says
02. Inside the function, append the number 9 to lst
So this line

n.append(9)

shoud be

lst.append(9)

also the return statement should return lst


#3

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