Two motivating examples from the chapter are exceptions (something different happens on the fifth iteration) and having a regularly changing value in each cycle of a loop. This example shows both.


Repetition with Variation

Words = "one two three four five".split()
for i in range(len(Words)):
  if len(Words[i]) > 3:
     print "*" ,
  print i, Words[i]