Created
April 9, 2020 07:39
-
-
Save lakshay-arora/9dac4622640fbff854cbbddc8db4c605 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define a function to divide two numbers | |
def division(a, b): | |
# use the try statement where error may occur | |
try: | |
print(a/b) | |
# if the error occurs, handle it !! | |
except ZeroDivisionError: | |
print("Cannot divide by Zero!!") | |
# if no error occurs | |
else: | |
print("No Error occured!!") | |
division(10,0) | |
# >> Cannot divide by Zero!! | |
division(10,2) | |
# >> 5 | |
# >> No Error occured!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment