Python – Error Handling 1
Hi all, here are the samples for error handling with try/catch.
my_value = "0" try: print(10 / my_value) except ZeroDivisionError: print("Can't divide by zero") except: print("Not possible") When you run the code, here is the output Not possible
my_value = 0 try: print(10 / my_value) except ZeroDivisionError: print("Can't divide by zero") except: print("Not possible") When you rune the code, here is the output Can't divide by zero
my_value = 5 try: print(10 / my_value) except ZeroDivisionError: print("Can't divide by zero") except: print("Not possible") When you run the code, here is the output 2.0