for count in [ ]print(countprint('yescountprint('done counting 'for color in ['red''blue''green']print(colorin filewhere the interpreter does not need to respond immediatelythe blank line is not necessary insteadas with function definition or any other format with an indented blockyou indicate being past the indented block by dedenting here the following print statement has the same level of indentation as the for loop heading because they have the same level of indentationthey are executed in sequence hence in the code above"done counting is printed once after the first loop completes all of its repetitions execution of the program ends with another simple loop as with the indented block in functionit is important to get the indentation right alter the code aboveso the fourth line is indentedfor count in [ ]print(countprint('yescountprint('done counting 'changed so indented for color in ['red''blue''green']print(colorpredict the changeand run the code again to test loops are one of the most important features in programming while the for loop syntax is pretty simpleusing them creatively to solve problems (rather than just look at demonstrationis among the biggest challenges for many learners at an introductory level one way to simplify the learning curve is to classify common situations and patternsand give them names one of the simplest patterns is illustrated in all of the for loop examples so fara simple foreach loopfor each element of the sequencedo the same sort of thing with it stated as more pythonic pseudo-codefor item in sequencedo something with the current item (it would be even more like english if for were replace by for eachbut the shorter version is the one used by python in the for loop examples abovesomething is printed that is related to each item in the list printing is certainly one form of "do something"but the possibilities for "do somethingare completely generalwe can use for-each loop to revise our first example in the tutorial recall the code from madlib pyaddpick('animal'userpicksaddpick('food'userpicksaddpick('city'userpickseach line is doing exactly the same thingexcept varying the string used as the cuewhile repeating the rest of the line this is the for-each patternbut we need to list the sequence that the cues come from read the alternativefor cue in ['animal''food''city']addpick(cueuserpicksheading body seeing this feature requires the ability to abstract the general pattern from the group of examples this is essential for using loops effectively beginning with python