The For Loop
Until now, doing something to five items meant writing five lines. A for loop writes it once and runs it for every item in an iterable.
Read it as a sentence: for each item in this collection, do this.
✦ Indentation is not decoration in Python
The indented lines under `for ... :` are the loop body. Un-indent a line and it runs once, after the loop finishes. Python beginners lose hours to this. JavaScript uses braces, so its indentation is only for humans, but indent it anyway, for the humans.
Mark this lesson complete
Signed in, your progress follows you to every device.