8/9 Iteration Confusion



The code I have is correct but I would really appreciate someone explaining to me how the for loops works. What I do not understand is how student in students iterates through each students assigned dictionary list values when students was never assigned any values as a variable.

I suspect it has something to do with the concept of passing arguments but I cannot find information on this that gets the point across.

Many thanks in advance.

def get_class_average(students):
    results = []
    for student in students:


This is a list of object identifiers that points to each dictinary. It acts as an index.

student in students

The iterator variable takes one value at a time from the list. It now points to one dictionary.


Thank you for your response.

How does students point to each dictionary without it being previously specified? That is the part that confuses me and I feel there is a simple concept that I'm missing.

Apologies if I'm not being clear enough or if this is a silly question.

Thanks again.


student => [
    lloyd    # first iteration
    alice    # second
    tyler    # third iteration
] in students


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