# 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")
man, it's strange to say that but at first: thank you so much, i like people like you who help us a lot for free and also with a very good content i want to ask you to read about islam if u r not a muslim and try to read quran and Allah, i won't ask for more, just try reading about these topic in the intention of knowing the truth and following it. i just asked for this because i want to say thank your in a very good way, and i hope you don't get it wrong. btw keep this brilliant content and videos and thx again. take care
So.... you know when people say i wish i could like this video 100 times, well i liked it twice, once on my phone and once on my laptop where i was taking notes from. Bro? How you make that so easy when 50 minutes ago i was sweating this topic? Now i can move on with confidence because im a bro learner 😂 Thanks Bro ❤
Right now i'm at my first semester in college and learning python became confusing since my teacher isn't helping much... Thanks to your videos, now I finally understand a lot of stuff. I'm currently studying for my text tomorrow and your videos are helping me a lot!! Thanks for taking your time to explain everything to us, and keep being the goat you are :]
Best code teacher I've ever seen!!! I know it's prolly easy for you, but I learned more from 3 of your videos than I learned from a week of Chat GPT. Thanks my dude!!! Will like and sub!!!!
@@damansomaiah6535A clear reason to not simply except all exceptions is that you prevent the original exception message from being presented to the user. "Something went wrong" is less useful to the user than whatever error message the underlying code would have given.
Fun fact: an inability to divide by zero is a myth. Common convention says you can't, and that's fine for most framings, but other conventions involve division by zero to equal either zero or infinity. All three options are 'correct' in their own way, with different advantages and disadvantages to each approach.
Thank you! This got to the point for a beginner like me and it was easy to understand and execute, without exception. Also, can I be a sis, rather than a bro?
Question from newbie: and how to do this on large file? i.e. do you create separate .py file to handle errors or we need to do it this way? Thank you in advance
If we want to only take the number part when there is an exception, we can say that the user entered the number 21a by mistake. How can we extract only the int part and ignore the string part?
guys Im currently following this playlist to learn python, Im just wondering if this is enough for me to start solving leetcode problems or I need to learn more method or syntaxes or something else?
# 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")
Can we use elif instead of except??
@@ArafatMohammedAsif I don't think so, cause you can't print what kind of exception
man, it's strange to say that but at first: thank you so much, i like people like you who help us a lot for free and also with a very good content
i want to ask you to read about islam if u r not a muslim and try to read quran and Allah, i won't ask for more, just try reading about these topic in the intention of knowing the truth and following it.
i just asked for this because i want to say thank your in a very good way, and i hope you don't get it wrong.
btw keep this brilliant content and videos and thx again.
take care
this man in single handily gonna get me through my programming course
Best video I've seen on exception handling. Simple, clear, and straightforward.
So.... you know when people say i wish i could like this video 100 times, well i liked it twice, once on my phone and once on my laptop where i was taking notes from. Bro? How you make that so easy when 50 minutes ago i was sweating this topic? Now i can move on with confidence because im a bro learner 😂 Thanks Bro ❤
Right now i'm at my first semester in college and learning python became confusing since my teacher isn't helping much... Thanks to your videos, now I finally understand a lot of stuff. I'm currently studying for my text tomorrow and your videos are helping me a lot!! Thanks for taking your time to explain everything to us, and keep being the goat you are :]
Best code teacher I've ever seen!!! I know it's prolly easy for you, but I learned more from 3 of your videos than I learned from a week of Chat GPT. Thanks my dude!!! Will like and sub!!!!
Watched some other tutorials which just weren't clear to me at all, but your tutorial made me fully understand it. Thank you!
Always great tutorials, never stop making excellent tutorials
You are excellent exception in python programming ... You explain so perfectly...thank you😁
Thank you bro...because of you i have come this far .
Very soon I will cover this playlist.
Never stop making videos.
I will always be grateful to you
I just started to learn Python and i wanted to thank you for the good videos . Thanks !
Didn't know the term 'exception handling', but this video helped me tremendously after I typed in my problem. Thank you!
That is pretty easy to understand that I find my thoughts circling in the class. Thank you bro
2:00 damn so when websites say something went wrong its just the developers being lazy lol
Not really, it's practically impossible to cover every single possible error in a website, if you get the ones that are covered though it will specify
@@damansomaiah6535A clear reason to not simply except all exceptions is that you prevent the original exception message from being presented to the user. "Something went wrong" is less useful to the user than whatever error message the underlying code would have given.
Or you are not supposed to know, that might be bad for their PR
The best video i have watched so far that explains exception handling in very easy to understand way. Thanks Bro, for the video
Nice! Glad my professor showed me this channel :)
The official docs make a lot of sense now after this video. Thnx!
As usual, Bro nailed it 💪
Hell yeah!👍 You are the best teacher I've ever found
I must say that this was an EXCEPTIOANALLY great tutorial video..!
Fun fact: an inability to divide by zero is a myth. Common convention says you can't, and that's fine for most framings, but other conventions involve division by zero to equal either zero or infinity. All three options are 'correct' in their own way, with different advantages and disadvantages to each approach.
Great tutorial, really got to know this concept. Thanks❤
great video, i finally got to understand what exception handling is
thank you bro i made the mistake of not putting the input thingys inside the try statements and now i fixed it
ıdk what to comment but here is one to support you bc you support us big guy
this is the stuff I like on my RUclips feed!! thanks Bro
I hope you know how much of a difference you make for people ❤
your videos helped me alot, thanks man keep it up :)
Bro makes learning coding easy!!!
Thank you so much! This video helped to understand my homework!!
Your youtube channel + Programming for Everybody (Getting Started with Python) on Coursera, the best way to learn Python !
HOW LONG AGO DID YOU TAKE COURSERA'S COURSE?
Bro Code ,you're the best
Very easy to understand ....thank you so much😊
You rock...Keep up good work
Pre-eminent tutorial !! Thank You
Great way of explaination
😄
your the goat of this generation ;)
These videos just cannot be disliked ❤
amazing man this is what i was looking for.
Thank you bro,watching from republic of mindanao
good
May God bless you for this!
You are grateful
Nice explanation, thanks for the video
Great lecture 🤯
Explanations so good I fail NNN from coding euphoria
excelent video thank you so much
Loved the content
Dude YOU ARE THE BEST EVER!!!!
Quality content bro
ur the reason im getting my cs degree.
2:55 the most Dwight Schrute thing I've ever heard 😂
😂😂😂I was going to comment the same, identity theft is not a joke!!!😂
@@FaizanShaikh-dq1fs Beets, Bears, Battlestar Galactica
@@laurabassino6721 "Micheal Micheal " lol , btw did you complete all python course of bro code?
@@FaizanShaikh-dq1fs not yet
@Laura Bassino 🤣🤣
Nice work. Thanks!
Good vid once again🙂
thanks man you realy are hero for real
amazing😍😍
exceptional 😀
I FINALLY CATCH IT THANKKKKS ...
i learned a lot, thanks
Thx for teaching
🎉🎉🎉
Duuuude this video was awesome 👌 👏 👍 😍
very nice class
amazing !
love your vids
Thanks!!🌷🌷
What does try keywords do?
Thank you Broseph Broestar
Absolutely great
Much appreciated
Bro you are awesome
Nice
Thank you!!
Thank you! This got to the point for a beginner like me and it was easy to understand and execute, without exception. Also, can I be a sis, rather than a bro?
niceeee😍
I like the "You can't divide by zero! Idiot!" I had just finished typing "You fucked up hard" to print under 'except Exception:'
Thanks for the video bro
Is finally block is useful?
We can also add a statement in last also
Thanks.... God bless you....
Question from newbie: and how to do this on large file? i.e. do you create separate .py file to handle errors or we need to do it this way? Thank you in advance
If we want to only take the number part when there is an exception, we can say that the user entered the number 21a by mistake. How can we extract only the int part and ignore the string part?
Thanks bro ❤️
Nice Video!
well explained
good tutor bro
guys Im currently following this playlist to learn python, Im just wondering if this is enough for me to start solving leetcode problems or I need to learn more method or syntaxes or something else?
great vid!
Thanks,bro
bro is cooking man
good teach🍕
Great!
Bro so underrated
Do game developer always put their entire codes inside a try-except-finally block?
Yo bro cool vid
Thank you!
thanks for this video 58 more videos to go
Bro code is great
Thanks dude
So cool
NICE!
thx bro