โ Back to Exceptions
Question 671
Catch Any Exception
Catch Any Exception
Read an integernand print100 / n. Instead of catching a specific type, catch the baseExceptiontype so any failure is handled, and print exactlySomething went wrong. Use top-level statements withtry/catch. Input4prints: 25 Input0prints: Something went wrong
Expected Output:
25
Topics:
Exceptions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.