Created
April 23, 2017 19:09
-
-
Save jayeye/01eadaa8b679df6e52152ba02760d6cb to your computer and use it in GitHub Desktop.
Hacky way of breaking out of an inner loop. Definitely better than having a flag and testing it.
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
class _iloop(Exception): | |
pass | |
try: | |
for i in range(2, 10): | |
for j in range(2, 10): | |
if i == j * j: | |
raise _iloop | |
print(i, j) | |
except _iloop: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment