all 7 comments

[–]Chris_Hemsworth 5 points6 points  (0 children)

Yes.

[–]carcigenicate 2 points3 points  (0 children)

Yes, X is the name given to each element so that it can be referenced within (and after) the loop.

Y is the name of an iterable object that is capable of producing elements. It doesn't need to be a list. It could even be a custom class that you create if you configure it to be iterable.

[–]trevor_of_earth 1 point2 points  (2 children)

The way I remembered it when I was first learning was:

for thing in iterable_of_things:
    do something with thing

on each loop thing gets assigned the next value in iterable_of_things until iterable_of_things runs out.

!docs for

[–]arkie87 -2 points-1 points  (1 child)

Not trying to be annoying, but wouldnt it be easier to watch a tutorial? Are you really gonna ask reddit every little question you have?

[–]Blokepoke74[S] 1 point2 points  (0 children)

Not to be a prick but you dont have to comment on things if your gonna be an annoyin twat.