some of the details regarding their roles as iterables in python were intentionally cut short in the next we continue the iteration story by discussing list comprehensions and the iteration protocol in python--concepts strongly related to for loops therewe'll also give the rest of the picture behind the iterable tools we met heresuch as range and zipand study some of the subtleties of their operation as alwaysthoughbefore moving on let' exercise what you've picked up here with quiz test your knowledgequiz what are the main functional differences between while and for what' the difference between break and continue when is loop' else clause executed how can you code counter-based loop in python what can range be used for in for looptest your knowledgeanswers the while loop is general looping statementbut the for is designed to iterate across items in sequence or other iterable although the while can imitate the for with counter loopsit takes more code and might run slower the break statement exits loop immediately (you wind up below the entire while or for loop statement)and continue jumps back to the top of the loop (you wind up positioned just before the test in while or the next item fetch in for the else clause in while or for loop will be run once as the loop is exitingif the loop exits normally (without running into break statementa break exits the loop immediatelyskipping the else part on the way out (if there is one counter loops can be coded with while statement that keeps track of the index manuallyor with for loop that uses the range built-in function to generate successive integer offsets neither is the preferred way to work in pythonif you need to simply step across all the items in sequence insteaduse simple for loop insteadwithout range or counterswhenever possibleit will be easier to code and usually quicker to run the range built-in can be used in for to implement fixed number of repetitionsto scan by offsets instead of items at offsetsto skip successive items as you goand to change list while stepping across it none of these roles requires rangeand most have alternatives--scanning actual itemsthree-limit slicesand list comprehensions are often better solutions today (despite the natural inclinations of ex- programmers to want to count things! while and for loops