add snippet try else

This commit is contained in:
Lazar Gugleta
2019-10-11 23:26:36 +02:00
parent f7d3501817
commit c0781a97c6

18
snippets/try_else.md Normal file
View File

@ -0,0 +1,18 @@
---
title: Try else
tags: utility,intermediate
---
Rises an `exception` if it is caught in the `try` block.
You can have an else clause as part of a `try/except` block, which is executed if no `exception` is thrown.
```py
try:
5*6
except TypeError:
print("An exception was raised")
else:
print("No exceptions were raised.")
```