How does this work or why it does not work :)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 15

How does this work or why it does not work :)?

https://code.sololearn.com/c6NYCq8b1I1y/?ref=app

28th Feb 2018, 3:38 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
5 Answers
+ 15
Thanks ! ! !
28th Feb 2018, 3:57 PM
Vučko/Вучко/Vuchko
Vučko/Вучко/Vuchko - avatar
28th Feb 2018, 3:51 PM
📈SmileGoodHope📈
📈SmileGoodHope📈 - avatar
+ 3
https://code.sololearn.com/cC9tijb0w2VE/#py # Testing DIV/0 exception catching try: num1 = 7 num2 = 0 print (num1 / num2) print("Done calculation") except ZeroDivisionError: print("An error occurred") print("due to zero division") # Testing normal functionality try: num1 = 7 num2 = 1 print (num1 / num2) print("Done calculation") except ZeroDivisionError: print("An error occurred") print("due to zero division")
28th Feb 2018, 3:42 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 3
I think?? that you are tried to perform nested try, except block.... Just two modification for that...give 'colan' and 'intention' for except...in your code... And thanks for your question I didn't know this before...... Modification of your code .. https://code.sololearn.com/cbyQvStRoD3A/?ref=app
1st Mar 2018, 2:58 PM
Shivadharshini Nagaraju
Shivadharshini Nagaraju - avatar
+ 2
To explain why your code wasn't working, you got a couple things wrong on it. - You have a random 'try' right after your 'except' which will generate a compile error. - You have a random 'except' after your 'zerodivisionerror' except, which also causes a compile error. :::: CODE WITH ERROR :::: except ZeroDivisionError: try print("An error occurred") print("due to zero division") except ^remove the try and remove the last except.
28th Feb 2018, 3:43 PM
Fata1 Err0r
Fata1 Err0r - avatar