+ 8
Is it necessary to write type of error after 'except'??
2 Answers
+ 2
A reduced way to get information about an exception is like that:
try:
value += 2
except Exception as e:
print('error occurred: ',e)
# output:
# error occurred: name 'value' is not defined
+ 1
If you donât, it will catch all errors. This means that bugs can occur that you didnât expect and an unexpected or incorrect output can be given. It is considered a good practice to write the possible errors out