List manipulation (11/18)


#1

How is it that Python knows that I want to manipulate the list outside of the function? What if I had two lists outside of this function? What kind of magicry is this?

n = [3, 5, 7]

def list_extender(lst):
lst.append(9)
return lst

print list_extender(n)


#2

You told it to.
You made a list named n
Then made a function that takes a list and adds 9 to it
You printed the result of calling that function on your list n


#3

Thank you! I guess I was just overthinking it.


#4

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