| 1 | initial version |
Here are two example functions illustrating breaking out of while and for loops:
def f():
index = 0
while True:
print index
index += 1
if index >= 4:
break
def g():
for i in range(10):
if i >= 5:
continue
print i
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.