Computer Science - Text-Based Programming - Python - Exception handling (try-except) - Add Error Handling
Add try-except to unsafe code. P1: 'Safe division' → try: result = a / b; except ___: print('Cannot divide by zero') [ZeroDivisionError]. P2: 'Safe integer conversion' → try: age = int(user_input); except ___: print('Please enter a number') [ValueError]. P3: 'Safe file reading' → try: with open(file