Try except else
You can have an else clause as part of a try/except block, which is executed if no exception is thrown.
Python: 3.0    Fatos Morina    03 Jul 2021   1
Login to upvote
1
2
3
4
5
6
7
8
try:
    2*3
except TypeError:
    print("An exception was raised")
else:
    print("Thank God, no exceptions were raised.")

#Thank God, no exceptions were raised.
Copy | Download as: .py file   PNG
Share on: FB   Twitter   LinkedIn   WA
©2021 - code108labs   Contributors   Hosted on DigitalOcean   Partner website: pythoncircle.com