Is python smart enough to realise which print statement to print after having two except blocks?I.e just by typing zero division | Sololearn: Learn to code for FREE!
- 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?

8th Apr 2017, 7:08 PM
Cyndy Wasai
Cyndy Wasai - avatar
1 Answer
+ 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.
8th Apr 2017, 8:41 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar