Python Try / Except Exercises
Let’s check out some exercises that will help understand Try / Except better.
Exercise 3-a: ZeroDivisionError Exception w/ Try Except Statements
Place result="You can't divide with 0" to the right place so that program avoids ZeroDivisionError.
Exercise 3-b: pass statement inside Try Except Statements
.get() is not a list method. Place pass keyword to the right line so that program doesn't throw an error.
Exercise 3-c: except Exception w/ Try Except Statements
Place msg="You can't add int to string" to the right place so that program avoids BaseExceptionError.
You can use except Exception although normally you should be careful using such powerful exception statements.
Need More Exercises?
Check out Holy Python AI+ for amazing Python learning tools.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython
Founder of HolyPython