This commit is contained in:
adii1823
2021-10-28 17:39:13 +05:30
parent b6eb3ef8a7
commit 32c12d89f4
11 changed files with 301 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
# exceptions/for.loop.py
n = 100
found = False
for a in range(n):
if found: break
for b in range(n):
if found: break
for c in range(n):
if 42 * a + 17 * b + c == 5096:
found = True
print(a, b, c) # 79 99 95
class ExitLoopException(Exception):
pass
try:
n = 100
for a in range(n):
for b in range(n):
for c in range(n):
if 42 * a + 17 * b + c == 5096:
raise ExitLoopException(a, b, c)
except ExitLoopException as ele:
print(ele.args) # (79, 99, 95)