+ 1
try except python
why is this code returning 3. Can someone explain this code to me? https://code.sololearn.com/cx4UUiDD5TCf
1 Réponse
+ 1
1/0 raise divideByzero exception , in
Catching also 1/0 , again raise error but it has no exception catching, comes out but after finally gets executed so finally returns 3
Finally block always executed whether exception raise or not..
so that's why it prints 3, even without exception also...
try 1/2 instead of 1/0 , answer will be same.