Created
November 26, 2013 23:15
-
-
Save jjfajardo/7668013 to your computer and use it in GitHub Desktop.
how to break nested for loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#Example written by jfajardo. 2013 | |
# This trivial program shows how to break to nested for loops, when a | |
# condition is TRUE | |
for letter in 'murcielago': | |
for i in range(10): | |
if(letter == "c" and i == 2): | |
break | |
print letter, i | |
else: | |
continue # executed if the loop ended normally (no break) | |
break # executed if 'continue' was skipped (break) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment