Product SiteDocumentation Site

6.10. Else loop

We can have an optional else statement after any loop. It will be executed after the loop unless a break statement stopped the loop.
>>> for i in range(0,5):
...     print i
... else:
...     print "Bye bye"
...
0
1
2
3
4
Bye bye

We will see more example of break and continue later in the book.