Commit 77018acf by Patryk Czarnik

teoria wyjątków - else

parent 3cc27b00
......@@ -7,8 +7,11 @@ try:
print('Wynik dzielenia:', iloraz)
except ZeroDivisionError as e:
print(f'Dzielenie przez zero')
else:
print('else teraz się wykonuje')
# else wykonuje się po wykonaniu try, jeśli nie było żadnego wyjątku
finally:
print('Finally zawsze się wykona')
print('finally zawsze się wykona')
# finally wykona się w każdej sytuacji:
# 1) fragment programu w try bez błędów dojdzie do końca
# 2) nastąpi wyjątek obsłużony w except
......@@ -16,3 +19,4 @@ finally:
# 4) gdy wyjdziemy w tego fragmentu kodu w inny sposób: return, break
print('Koniec programu')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment