Using elements from a list in a function

Ok so I am currently working on the lesson about Lists and Functions, and am on the exercise about using an element from a list in a function. The code is simple and I understand most of it, the only part I can’t explain is the correlation of the arguments of the function.

The same function in the exercise is set to have two different arguments, once as it is defined and again when the list is created and set as the function’s argument.

HOW is the first argument (which is being asked to return a value within the function) is able to call on that particular index from the list, which is later set as an argument.

All help is greatly appreciated in advance.

Apologies if I’ve mistinterpreted you but the parameter in the function does not have a value until you pass one when you call the function. You can think of that parameter as more of a placeholder. You can call the function more than once with a different list each time, each call has that parameter assigned to a list object with the x name forgotten once the function has finished executing (the name in the otuer scope remains unaffected though).

If it helps you could use a keyword argument which may be a little more explicit for now (keyword arguments themselves will likely be introduced at a later point). Here’s an example-

def list_function(x):
  return x

n = [1, 2, 3,]
m = ['a', 'b', 'c',]

In both these cases the call could isntead be list_function(n) or m but the effect is the same, the x is only assigned when that call is made and is forogtten once the function exits.

If that wasn’t what you were asking then my apologies, could you clarify a little if so?