Python exception handling ⚠️

Поділитися
Вставка
  • Опубліковано 2 лис 2024

КОМЕНТАРІ • 167

  • @BroCodez
    @BroCodez  3 роки тому +50

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

    • @arafatmohammadasifbamboowa2211
      @arafatmohammadasifbamboowa2211 2 роки тому +1

      Can we use elif instead of except??

    • @macklykyn8967
      @macklykyn8967 2 роки тому +1

      @@arafatmohammadasifbamboowa2211 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 7 місяців тому +7

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

  • @KarinFields
    @KarinFields 11 місяців тому +13

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

  • @passportbro904
    @passportbro904 Рік тому +28

    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 ❤

  • @samirsardar7817
    @samirsardar7817 25 днів тому

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

  • @shriniketkulkarni8169
    @shriniketkulkarni8169 Рік тому +4

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

  • @elliotradley4370
    @elliotradley4370 2 роки тому +12

    Always great tutorials, never stop making excellent tutorials

  • @Engmelli
    @Engmelli 2 роки тому +33

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

    • @damansomaiah6535
      @damansomaiah6535 10 місяців тому +8

      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 5 місяців тому

      ​@@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 4 місяці тому +1

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

  • @htetmyetthar5650
    @htetmyetthar5650 5 місяців тому +1

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

  • @AD-cc7bj
    @AD-cc7bj 7 місяців тому +1

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

  • @ТодорПарушев-и8ч
    @ТодорПарушев-и8ч 6 місяців тому +1

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

  • @BeanieK1
    @BeanieK1 7 місяців тому +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!!!!

  • @joelngige5776
    @joelngige5776 23 дні тому

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

  • @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

  • @donthiebautable
    @donthiebautable 4 місяці тому +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.

  • @SernaLovesYoongi
    @SernaLovesYoongi 3 місяці тому

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

  • @GabeSkorski
    @GabeSkorski 9 місяців тому +1

    Nice! Glad my professor showed me this channel :)

  • @swetankraut6065
    @swetankraut6065 9 місяців тому

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

  • @LauraAnna-vn7st
    @LauraAnna-vn7st 4 місяці тому

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

  • @Greenbay-bn3yk
    @Greenbay-bn3yk 5 місяців тому

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

  • @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?

  • @somthing7286
    @somthing7286 Рік тому

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

  • @ahmedalihenawy7054
    @ahmedalihenawy7054 6 місяців тому

    Great way of explaination
    😄

  • @theamithsingh
    @theamithsingh Рік тому +4

    As usual, Bro nailed it 💪

  • @misran449
    @misran449 Рік тому

    this is the stuff I like on my UA-cam feed!! thanks Bro

  • @X_habesha
    @X_habesha 9 місяців тому

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

  • @vincentb1771
    @vincentb1771 11 місяців тому

    Explanations so good I fail NNN from coding euphoria

  • @ilyassbabkhouti
    @ilyassbabkhouti Рік тому +1

    good

  • @piotrkopcewicz5227
    @piotrkopcewicz5227 2 роки тому +1

    Pre-eminent tutorial !! Thank You

  • @AndreiAcojido
    @AndreiAcojido 8 місяців тому

    Thank you bro,watching from republic of mindanao

  • @JustCoding-c6s
    @JustCoding-c6s 2 місяці тому

    your the goat of this generation ;)

  • @senaustun4380
    @senaustun4380 8 місяців тому

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

  • @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 🤣🤣

  • @Qustode
    @Qustode Рік тому

    Nice explanation, thanks for the video

  • @vekta-q19
    @vekta-q19 15 днів тому

    Bro Code ,you're the best

  • @kapibara2440
    @kapibara2440 Рік тому

    These videos just cannot be disliked ❤

  • @mariamsahak2130
    @mariamsahak2130 10 місяців тому

    May God bless you for this!

  • @thePRECIOUS_1
    @thePRECIOUS_1 9 місяців тому

    amazing man this is what i was looking for.

  • @bharathpavurala7817
    @bharathpavurala7817 Рік тому +1

    Great lecture 🤯

  • @thorcoder1
    @thorcoder1 3 роки тому +2

    You are grateful

  • @Gladysnjoki
    @Gladysnjoki 2 роки тому +1

    You rock...Keep up good work

  • @wenbinli9807
    @wenbinli9807 9 місяців тому

    very nice class

  • @tylerhopkins2868
    @tylerhopkins2868 2 роки тому +1

    Nice work. Thanks!

  • @OrhanAhmedov-h7z
    @OrhanAhmedov-h7z Рік тому

    Absolutely great

  • @W126-i5u
    @W126-i5u Рік тому

    Dude YOU ARE THE BEST EVER!!!!

  • @lw9954
    @lw9954 2 роки тому

    Thank you Broseph Broestar

  • @DC-sk8jr
    @DC-sk8jr 21 день тому

    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?

  • @alphad9474
    @alphad9474 2 роки тому +2

    amazing !

  • @sophiawang2400
    @sophiawang2400 Рік тому

    Thx for teaching
    🎉🎉🎉

  • @heal294
    @heal294 7 місяців тому

    love your vids

  • @PeakPotential766
    @PeakPotential766 6 місяців тому

    thanks man you realy are hero for real

  • @Dreamon-np5tb
    @Dreamon-np5tb 6 місяців тому

    Much appreciated

  • @soulexesns9522
    @soulexesns9522 24 дні тому

    Thank you!

  • @anuvhabbasu2599
    @anuvhabbasu2599 5 місяців тому

    Quality content bro

  • @saragh7006
    @saragh7006 2 роки тому +1

    I FINALLY CATCH IT THANKKKKS ...

  • @b7sh_b7sh
    @b7sh_b7sh 10 місяців тому

    amazing😍😍

  • @kumarmanglam815
    @kumarmanglam815 Рік тому

    exceptional 😀

  • @faresmohamed9447
    @faresmohamed9447 4 місяці тому

    i learned a lot, thanks

  • @arulsingh5741
    @arulsingh5741 3 роки тому +1

    Nice

  • @dineshgautam7027
    @dineshgautam7027 3 роки тому

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

  • @sadeghkhosravi
    @sadeghkhosravi Рік тому

    Thanks!!🌷🌷

  • @christianihechi
    @christianihechi 6 місяців тому

    Thank you!!

  • @GTV_367
    @GTV_367 Рік тому

    Good vid once again🙂

  • @mdyusufulhaque9953
    @mdyusufulhaque9953 Рік тому

    well explained

  • @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:'

  • @AbdulrahmonBabatunde-m4e
    @AbdulrahmonBabatunde-m4e 6 місяців тому

    Thanks bro!

  • @hakanerenaykac1742
    @hakanerenaykac1742 Рік тому

    print("Thank you Bro Code")

  • @muhammadnasiribrahim723
    @muhammadnasiribrahim723 2 місяці тому

    So cool

  • @manuela7477
    @manuela7477 Рік тому

    Great!

  • @NiLizee812
    @NiLizee812 8 місяців тому

    good tutor bro

  • @spartanranger
    @spartanranger 3 роки тому

    Thanks for the video bro

  • @johnwarner9102
    @johnwarner9102 Рік тому

    great vid!

  • @HunaBopa
    @HunaBopa Рік тому +1

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

  • @riceball7238
    @riceball7238 9 місяців тому

    thanks for this video 58 more videos to go

  • @matejgrasic4285
    @matejgrasic4285 Рік тому +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

  • @laopichthyrith2490
    @laopichthyrith2490 2 роки тому

    Bro so underrated

  • @dagim6625
    @dagim6625 9 місяців тому

    Thanks,bro

  • @yahyaazad2990
    @yahyaazad2990 Рік тому

    niceeee😍

  • @Tk_the_0ne
    @Tk_the_0ne 10 місяців тому

    bro is cooking man

  • @starplatinum6181
    @starplatinum6181 2 роки тому

    Nice Video!

  • @gamePlays9699
    @gamePlays9699 Рік тому

    NICE!

  • @shavindasilva
    @shavindasilva 2 роки тому +1

    something went right👌

  • @augustinegeorge633
    @augustinegeorge633 Рік тому

    Bro you are awesome

  • @gurudathg1328
    @gurudathg1328 2 роки тому

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

  • @RyanBalak-z2h
    @RyanBalak-z2h 3 роки тому

    Duuuude this video was awesome 👌 👏 👍 😍

  • @Mutable7
    @Mutable7 3 роки тому +1

    Thanks bro ❤️

  • @D.S.MANOJ15
    @D.S.MANOJ15 4 місяці тому

    Thanks dude

  • @scottjeffery4583
    @scottjeffery4583 6 місяців тому

    Thanks

  • @sajinvithayathil2158
    @sajinvithayathil2158 Рік тому

    thank you

  • @shawkir35
    @shawkir35 10 місяців тому

    Thanks bro

  • @gamePlays9699
    @gamePlays9699 Рік тому

    U r legend!

  • @grim-lf6de
    @grim-lf6de 20 днів тому

    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?

  • @afskils107
    @afskils107 Рік тому

    good teach🍕

  • @beingzero7541
    @beingzero7541 2 роки тому

    Wow!

  • @ManucherImomnazarov
    @ManucherImomnazarov 9 місяців тому

    The best

  • @Bro_Trade
    @Bro_Trade 10 місяців тому

    print("You are a legend")

  • @HussainAli-sb1dv
    @HussainAli-sb1dv Рік тому

    love u bro

  • @anurashik7584
    @anurashik7584 Рік тому

    thank you........