List Manipulation in functions - What's wrong here?


#1

n = [3, 5, 7]

Add your function here

def list_extender(lst):
n.append(9)
return 1st

print list_extender(n)

That's the code Ive used for this lesson, but I keep getting the following error message:

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

I can't see why even though the console produces the right answer. Am I missing something?


#2

Hi try to change your return 1st by return lst


#3

thanks, I just noticed that lol. I changed it, but i'm still getting the message that the right values aren't being returned, even though when the function is printed, the number 9 is appended in the right place


#4

try to change n.append(9) by lst.append(9)


#5

thanks. that worked appreciate it. I wonder how appending the list locally will change the global value of N to be returned outside of the function. Is it that the function scans the global list first?