Python exception handling ⚠️

Поделиться
HTML-код
  • Опубликовано: 4 фев 2025

Комментарии • 184

  • @BroCodez
    @BroCodez  4 года назад +55

    # 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")

    • @ArafatMohammedAsif
      @ArafatMohammedAsif 2 года назад +2

      Can we use elif instead of except??

    • @macklykyn8967
      @macklykyn8967 2 года назад +1

      @@ArafatMohammedAsif I don't think so, cause you can't print what kind of exception

    • @ghobashi2000
      @ghobashi2000 2 года назад +3

      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

  • @TheWeirdTeenager2010
    @TheWeirdTeenager2010 11 месяцев назад +10

    this man in single handily gonna get me through my programming course

  • @KarinFields
    @KarinFields Год назад +15

    Best video I've seen on exception handling. Simple, clear, and straightforward.

  • @passportbro904
    @passportbro904 Год назад +36

    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 ❤

  • @SonyuCD
    @SonyuCD 2 месяца назад +1

    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 :]

  • @BeanieK1
    @BeanieK1 10 месяцев назад +1

    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!!!!

  • @samirsardar7817
    @samirsardar7817 3 месяца назад

    Watched some other tutorials which just weren't clear to me at all, but your tutorial made me fully understand it. Thank you!

  • @elliotradley4370
    @elliotradley4370 2 года назад +12

    Always great tutorials, never stop making excellent tutorials

  • @shriniketkulkarni8169
    @shriniketkulkarni8169 Год назад +4

    You are excellent exception in python programming ... You explain so perfectly...thank you😁

  • @Amit-m1h
    @Amit-m1h Год назад +2

    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

  • @ТодорПарушев-и8ч
    @ТодорПарушев-и8ч 9 месяцев назад +1

    I just started to learn Python and i wanted to thank you for the good videos . Thanks !

  • @AD-cc7bj
    @AD-cc7bj 11 месяцев назад +1

    Didn't know the term 'exception handling', but this video helped me tremendously after I typed in my problem. Thank you!

  • @htetmyetthar5650
    @htetmyetthar5650 8 месяцев назад +1

    That is pretty easy to understand that I find my thoughts circling in the class. Thank you bro

  • @Engmelli
    @Engmelli 2 года назад +35

    2:00 damn so when websites say something went wrong its just the developers being lazy lol

    • @damansomaiah6535
      @damansomaiah6535 Год назад +10

      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

    • @2bfrank657
      @2bfrank657 8 месяцев назад

      ​@@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.

    • @DanielHai-ow3km
      @DanielHai-ow3km 7 месяцев назад +1

      Or you are not supposed to know, that might be bad for their PR

  • @joelngige5776
    @joelngige5776 3 месяца назад

    The best video i have watched so far that explains exception handling in very easy to understand way. Thanks Bro, for the video

  • @GabeSkorski
    @GabeSkorski Год назад +1

    Nice! Glad my professor showed me this channel :)

  • @SernaLovesYoongi
    @SernaLovesYoongi 6 месяцев назад

    The official docs make a lot of sense now after this video. Thnx!

  • @theamithsingh
    @theamithsingh 2 года назад +4

    As usual, Bro nailed it 💪

  • @Greenbay-bn3yk
    @Greenbay-bn3yk 9 месяцев назад

    Hell yeah!👍 You are the best teacher I've ever found

  • @swetankraut6065
    @swetankraut6065 Год назад

    I must say that this was an EXCEPTIOANALLY great tutorial video..!

  • @donthiebautable
    @donthiebautable 7 месяцев назад +1

    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.

  • @FootballMania-kc2yi
    @FootballMania-kc2yi 2 месяца назад

    Great tutorial, really got to know this concept. Thanks❤

  • @luanolveira6351
    @luanolveira6351 Месяц назад

    great video, i finally got to understand what exception handling is

  • @wishyouaway
    @wishyouaway Год назад

    thank you bro i made the mistake of not putting the input thingys inside the try statements and now i fixed it

  • @senaustun4380
    @senaustun4380 11 месяцев назад

    ıdk what to comment but here is one to support you bc you support us big guy

  • @misran449
    @misran449 Год назад

    this is the stuff I like on my RUclips feed!! thanks Bro

  • @casualdomo3202
    @casualdomo3202 7 дней назад

    I hope you know how much of a difference you make for people ❤

  • @X_habesha
    @X_habesha Год назад

    your videos helped me alot, thanks man keep it up :)

  • @nasiriqbal5475
    @nasiriqbal5475 Год назад +1

    Bro makes learning coding easy!!!

  • @JoseBeltranveles
    @JoseBeltranveles Год назад +1

    Thank you so much! This video helped to understand my homework!!

  • @kasmeneyes2227
    @kasmeneyes2227 Год назад +1

    Your youtube channel + Programming for Everybody (Getting Started with Python) on Coursera, the best way to learn Python !

    • @TheJossephc
      @TheJossephc Год назад

      HOW LONG AGO DID YOU TAKE COURSERA'S COURSE?

  • @vekta-q19
    @vekta-q19 3 месяца назад

    Bro Code ,you're the best

  • @LauraAnna-vn7st
    @LauraAnna-vn7st 7 месяцев назад

    Very easy to understand ....thank you so much😊

  • @Gladysnjoki
    @Gladysnjoki 2 года назад +1

    You rock...Keep up good work

  • @piotrkopcewicz5227
    @piotrkopcewicz5227 2 года назад +1

    Pre-eminent tutorial !! Thank You

  • @ahmedalihenawy7054
    @ahmedalihenawy7054 9 месяцев назад

    Great way of explaination
    😄

  • @JustCoding-c6s
    @JustCoding-c6s 6 месяцев назад

    your the goat of this generation ;)

  • @kapibara2440
    @kapibara2440 Год назад

    These videos just cannot be disliked ❤

  • @thePRECIOUS_1
    @thePRECIOUS_1 Год назад

    amazing man this is what i was looking for.

  • @AndreiAcojido
    @AndreiAcojido 11 месяцев назад

    Thank you bro,watching from republic of mindanao

  • @ilyassbabkhouti
    @ilyassbabkhouti Год назад +1

    good

  • @mariamsahak2130
    @mariamsahak2130 Год назад

    May God bless you for this!

  • @thorcoder1
    @thorcoder1 3 года назад +2

    You are grateful

  • @Qustode
    @Qustode Год назад

    Nice explanation, thanks for the video

  • @bharathpavurala7817
    @bharathpavurala7817 2 года назад +1

    Great lecture 🤯

  • @vincentb1771
    @vincentb1771 Год назад

    Explanations so good I fail NNN from coding euphoria

  • @darleyguti1035
    @darleyguti1035 2 месяца назад

    excelent video thank you so much

  • @AryanSachdeva-t5h
    @AryanSachdeva-t5h Месяц назад

    Loved the content

  • @W126-i5u
    @W126-i5u Год назад

    Dude YOU ARE THE BEST EVER!!!!

  • @anuvhabbasu2599
    @anuvhabbasu2599 8 месяцев назад

    Quality content bro

  • @cenpire
    @cenpire Месяц назад

    ur the reason im getting my cs degree.

  • @laurabassino6721
    @laurabassino6721 3 года назад +3

    2:55 the most Dwight Schrute thing I've ever heard 😂

    • @FaizanShaikh-dq1fs
      @FaizanShaikh-dq1fs 3 года назад +1

      😂😂😂I was going to comment the same, identity theft is not a joke!!!😂

    • @laurabassino6721
      @laurabassino6721 3 года назад

      @@FaizanShaikh-dq1fs Beets, Bears, Battlestar Galactica

    • @FaizanShaikh-dq1fs
      @FaizanShaikh-dq1fs 3 года назад

      @@laurabassino6721 "Micheal Micheal " lol , btw did you complete all python course of bro code?

    • @laurabassino6721
      @laurabassino6721 3 года назад

      @@FaizanShaikh-dq1fs not yet

    • @gurudathg1328
      @gurudathg1328 2 года назад

      @Laura Bassino 🤣🤣

  • @tylerhopkins2868
    @tylerhopkins2868 2 года назад +1

    Nice work. Thanks!

  • @GTV_367
    @GTV_367 Год назад

    Good vid once again🙂

  • @PeakPotential766
    @PeakPotential766 9 месяцев назад

    thanks man you realy are hero for real

  • @b7sh_b7sh
    @b7sh_b7sh Год назад

    amazing😍😍

  • @kumarmanglam815
    @kumarmanglam815 Год назад

    exceptional 😀

  • @saragh7006
    @saragh7006 2 года назад +1

    I FINALLY CATCH IT THANKKKKS ...

  • @faresmohamed9447
    @faresmohamed9447 7 месяцев назад

    i learned a lot, thanks

  • @sophiawang2400
    @sophiawang2400 Год назад

    Thx for teaching
    🎉🎉🎉

  • @RyanBalak-z2h
    @RyanBalak-z2h 3 года назад

    Duuuude this video was awesome 👌 👏 👍 😍

  • @wenbinli9807
    @wenbinli9807 Год назад

    very nice class

  • @alphad9474
    @alphad9474 3 года назад +2

    amazing !

  • @heal294
    @heal294 10 месяцев назад

    love your vids

  • @sadeghkhosravi
    @sadeghkhosravi Год назад

    Thanks!!🌷🌷

  • @agastyaadesh7848
    @agastyaadesh7848 3 месяца назад +2

    What does try keywords do?

  • @lw9954
    @lw9954 2 года назад

    Thank you Broseph Broestar

  • @OrhanAhmedov-h7z
    @OrhanAhmedov-h7z Год назад

    Absolutely great

  • @Dreamon-np5tb
    @Dreamon-np5tb 9 месяцев назад

    Much appreciated

  • @augustinegeorge633
    @augustinegeorge633 Год назад

    Bro you are awesome

  • @arulsingh5741
    @arulsingh5741 4 года назад +1

    Nice

  • @christianihechi
    @christianihechi 9 месяцев назад

    Thank you!!

  • @DC-sk8jr
    @DC-sk8jr 3 месяца назад

    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?

  • @yahya_azad
    @yahya_azad Год назад

    niceeee😍

  • @siciliandragon8654
    @siciliandragon8654 Год назад

    I like the "You can't divide by zero! Idiot!" I had just finished typing "You fucked up hard" to print under 'except Exception:'

  • @spartanranger
    @spartanranger 3 года назад

    Thanks for the video bro

  • @gurudathg1328
    @gurudathg1328 2 года назад

    Is finally block is useful?
    We can also add a statement in last also

  • @dineshgautam7027
    @dineshgautam7027 3 года назад

    Thanks.... God bless you....

  • @matejgrasic4285
    @matejgrasic4285 2 года назад +1

    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

  • @grim-lf6de
    @grim-lf6de 3 месяца назад

    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?

  • @Bhupendra7799
    @Bhupendra7799 3 года назад +1

    Thanks bro ❤️

  • @TenMansVideoOfDemand
    @TenMansVideoOfDemand 2 года назад

    Nice Video!

  • @mdyusufulhaque9953
    @mdyusufulhaque9953 Год назад

    well explained

  • @NiLizee812
    @NiLizee812 11 месяцев назад

    good tutor bro

  • @hungnguyentien1223
    @hungnguyentien1223 8 месяцев назад

    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?

  • @johnwarner9102
    @johnwarner9102 2 года назад

    great vid!

  • @dagim6625
    @dagim6625 Год назад

    Thanks,bro

  • @Tk_the_0ne
    @Tk_the_0ne Год назад

    bro is cooking man

  • @afskils107
    @afskils107 Год назад

    good teach🍕

  • @manuela7477
    @manuela7477 2 года назад

    Great!

  • @laopichthyrith9
    @laopichthyrith9 2 года назад

    Bro so underrated

  • @HunaBopa
    @HunaBopa Год назад +1

    Do game developer always put their entire codes inside a try-except-finally block?

  • @DanielHai-ow3km
    @DanielHai-ow3km 7 месяцев назад

    Yo bro cool vid

  • @kemann3815
    @kemann3815 2 года назад

    Thank you!

  • @riceball7238
    @riceball7238 Год назад

    thanks for this video 58 more videos to go

  • @ahmetunaldi7601
    @ahmetunaldi7601 3 месяца назад

    Bro code is great

  • @D.S.MANOJ15
    @D.S.MANOJ15 7 месяцев назад

    Thanks dude

  • @muhammadnasiribrahim723
    @muhammadnasiribrahim723 5 месяцев назад

    So cool

  • @gamePlays9699
    @gamePlays9699 2 года назад

    NICE!

  • @techlace1195
    @techlace1195 2 года назад

    thx bro