Using two lists as two arguments in a function


Hi I’m trying to understand how the following code works. I’m lost.

m = [1, 2, 3]
n = [4, 5, 6]

Add your code here!

def join_lists(x, y):
return x + y

print join_lists(m, n)

You want this to print [1, 2, 3, 4, 5, 6]

How is that the function arguments know which list they should use? How does x know it is taking the data from list ''n" and the same for y in list “m”. I simply don’t understand how it knows what to use?

Can someone help explain this?




what you use here is known as positional arguments, the name gives a big clue about how it works. the first argument (m) will pass it value to the first parameter (x), same for second argument and parameter


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