- 2
Is python smart enough to realise which print statement to print after having two except blocks?I.e just by typing zero division
just by typing "zero division error" or "name error" can it distinguish it from the lines of code automatically and print the correct statement?
1 ответ
+ 5
It is smart, provided that exception clauses are mutually exclusive. If you first write except: and later on except ValueError:, the first except, as it encompasses all cases, will get executed.