0

In python the except block need to contain the error or we can just use it without the error name??

6th Jun 2022, 11:15 AM
Purple Phoenix 7
Purple Phoenix 7 - avatar
2 ответов
0
yes you can do a catch without any Exceptions in it, it should catch any Exceptions try: 5/0 # throws ZeroDivisionError except: print("an error happened")
6th Jun 2022, 2:41 PM
Apollo-Roboto
Apollo-Roboto - avatar
0
I can say from experience that catching all can lead to problem as the code gets more complex. Sometimes it's important to know exactly what error you are receiving to make your code run more smoothly
6th Jun 2022, 2:45 PM
Apollo-Roboto
Apollo-Roboto - avatar