Python exception handling ⚠️

Поделиться
HTML-код
  • Опубликовано: 30 ноя 2024
  • НаукаНаука

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

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

    # 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 8 месяцев назад +8

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

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

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

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

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

    • @damansomaiah6535
      @damansomaiah6535 11 месяцев назад +9

      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 6 месяцев назад

      ​@@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 5 месяцев назад +1

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

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

    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 ❤

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

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

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

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

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

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

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

    Always great tutorials, never stop making excellent tutorials

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

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

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

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

  • @PeriMochi
    @PeriMochi 12 дней назад

    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 8 месяцев назад +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!!!!

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

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

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

  • @donthiebautable
    @donthiebautable 5 месяцев назад +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 4 месяца назад

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

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

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

  • @FootballMania-kc2yi
    @FootballMania-kc2yi 17 дней назад

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

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

    Nice! Glad my professor showed me this channel :)

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

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

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

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

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

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

    Bro makes learning coding easy!!!

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

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

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

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

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

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

    Explanations so good I fail NNN from coding euphoria

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

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

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

    As usual, Bro nailed it 💪

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

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

    Great way of explaination
    😄

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

    These videos just cannot be disliked ❤

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

    Thank you bro,watching from republic of mindanao

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

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

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

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

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

    Nice explanation, thanks for the video

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

    Pre-eminent tutorial !! Thank You

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

    good

  • @darleyguti1035
    @darleyguti1035 15 дней назад

    excelent video thank you so much

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

    You rock...Keep up good work

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

    your the goat of this generation ;)

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

    Great lecture 🤯

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

    Thank you Broseph Broestar

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

    very nice class

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

    Bro Code ,you're the best

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

    May God bless you for this!

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

    Nice work. Thanks!

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

    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?

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

    Quality content bro

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

    amazing😍😍

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

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

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

    print("Thank you Bro Code")

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

    You are grateful

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

    Thx for teaching
    🎉🎉🎉

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

    exceptional 😀

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

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

    well explained

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

    Nice

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

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

  • @agastyaadesh7848
    @agastyaadesh7848 25 дней назад +1

    What does try keywords do?

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

    Good vid once again🙂

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

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

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

    amazing man this is what i was looking for.

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

    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?

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

    bro is cooking man

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

    something went right👌

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

    amazing !

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

    Dude YOU ARE THE BEST EVER!!!!

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

    good tutor bro

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

    Bro so underrated

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

    Absolutely great

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

    Duuuude this video was awesome 👌 👏 👍 😍

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

    Much appreciated

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

    thanks for this video 58 more videos to go

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

    Thanks for the video bro

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

    thanks man you realy are hero for real

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

    what is the point of having an "else" statement?
    because if an error occurred then nothing would be outputted anyways so whats the point

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

    Nice Video!

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

    Thank you!!

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

    Thanks!!🌷🌷

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

    niceeee😍

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

    I FINALLY CATCH IT THANKKKKS ...

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

    love your vids

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

    Great!

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

    i learned a lot, thanks

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

    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?

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

    good teach🍕

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

    😎😎

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

    How would I make it say that {whatever you typed in} is not a number

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

    Thanks bro ❤️

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

    great vid!

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

    for the youtube algorithm

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

    Thanks,bro

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

    Bro you are awesome

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

    Good job broo :)

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

    Thank you!

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

    Bro code for life

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

    he sounds like joe form family guy

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

    So cool