Python exception handling ⚠️

9 Views
Published
Python exception handling tutorial example explained

#python #exception #exceptions

# exception = events detected during execution that interrupt the flow of a program

try:
numerator = int(input("Enter a number to divide: "))
denominator = int(input("Enter a number to divide by: "))
result = numerator / denominator
except ZeroDivisionError as e:
print(e)
print("You can't divide by zero! idiot!")
except ValueError as e:
print(e)
print("Enter only numbers plz")
except Exception as e:
print(e)
print("something went wrong :(")
else:
print(result)
finally:
print("This will always execute")

––––––––––––––––––––––––––––––
Up In My Jam (All Of A Sudden) by - Kubbi https://soundcloud.com/kubbi
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
Free Download / Stream: http://bit.ly/2JnDfCE
Music promoted by Audio Library https://youtu.be/tDexBj46oNI
––––––––––––––––––––––––––––––
Category
Bro Code
Tags
Python (Programming Language), Python Tutorial, Python Tutorials
Be the first to comment