Hi, @bamboumis , and everyone else.
It is important to format code when you post it. That enables users to see your indentation and other important details.
See How do I format code in my posts?.
@bamboumis , following is your function definition, with indentation, and it is correct, even if
students has not yet been defined in your code...
results = 
for student in students:
The function definition does not actually give its parameter,
students, a value. In fact,
students is just a name that does not refer to anything until the function is used, or called. When you actually call the function, you will provide the parameter,
students, with a definition by specifying an argument in parentheses, which needs to be a reference to an appropriate
list. At that time the function's code, including the loop, will execute.
In Exercise 3: Put It Together, you were asked to do this ...
Below your code, create a list called
students that contains
So, you should have this statement in your code, just below
tyler's dictionary ...
students = [lloyd, alice, tyler]
It is important to note that this does not assign a value to the function parameter that is also named
students. The global variable,
students, created by the above assignment statement is not the same variable as the function parameter, even though they both have the same name.
Assuming that you have defined the global variable,
students, you could call the function, as follows ...
Note that you could also do something like this to have the function provide results for a different group of students ...
coding_club = [alice, tyler]
It does not matter that the name of the argument in the function call is different from the name of the parameter in the function definition. The above example underscores the fact that the function parameter is given its reference to an object at the time that the function is called. That object, regardless of what it is named in the function call, is referred to as
students within the function.