That's right -- for the accumulator pattern, it's important that you update the value of the accumulator variable (totStudents) each time through the loop, but you don't just want to set it to be EQUAL to the current number of students. You want to assign it to whatever it was before (totStudents) PLUS the new number of students, so that it accumulates more students each time through the loop.
In the example from class, we did
for i in range(...):
theSum = theSum + i * i
where i
was the FOR loop variable going through the range of odd numbers.
Or alternatively, if we used odd
as the FOR loop variable, then:
for odd in range(...):
oddSquared = odd * odd
theSum = theSum + oddSquared