More with 'for' (9/14) question (includes spoilers)


#1

Greetings, and apologizes in advance if this is an obvious question :slight_smile:

I was stuck on this lesson and ended up just giving up and looking at the solution. When I saw the answer, I was still confused so I figured I would ask. I did not see anywhere in the for loop where number is either initiated or iterated. What I mean by that is that I didn’t see something like

number = 0

for number in start_list:
square_list.append(number ** 2)
number++

So my question is, how does Python know how to go through the loop without being initiated or iterated? Is it just that number isn’t a variable name but a type? Also, sorry if my terminology is off, it’s been over a decade since I took a computer science class :smile:

Thanks in advance!


#2

This for loop header defines number as a variable and establishes a loop that iterates through start_list, assigning each value, in turn, to number

for number in start_list:

number is not a type in Python. int and float are numerical types.


#3

Thanks for the explanation!


#4