Exception Handling in Python | Python Tutorial - Day #36

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ธ.ค. 2024

ความคิดเห็น • 381

  • @aishwaryaporwal2321
    @aishwaryaporwal2321 ปีที่แล้ว +159

    This guy never ever did any paid course after teaching for this many years on TH-cam.
    Huge respect for Harry bhai♥️♥️

    • @invincible4010
      @invincible4010 2 หลายเดือนก่อน

      Bhai TH-cam se earning

    • @aadilnazir8904
      @aadilnazir8904 หลายเดือนก่อน

      @@invincible4010 Bhai Paid b krr skta tha uss se zyda earning hote

  • @FaceSenseAustralia
    @FaceSenseAustralia ปีที่แล้ว +38

    Few important things to note about try and exception method:
    1. We can use else clause with exception handling.
    try:
    result = 100 / 2
    except ZeroDivisionError:
    print(f"Division Error")
    else:
    print("Result is", result)
    2. Using the finally clause in exception handling
    try:
    result = 10 / 0
    except ZeroDivisionError:
    print("Division by zero!")
    finally:
    print("This block of code will always execute.")
    3. Raising exceptions using raise
    try:
    raise ValueError("This is a custom error message.")
    except ValueError as e:
    print("An error occurred:", str(e))

  • @rudra2036
    @rudra2036 ปีที่แล้ว +6

    Error dikhane ka stylish way 😁😁😁😁😁😁😁😁
    # My code
    box=[]
    while(True):
    try:
    num = int(input("Enter num:"))
    for i in range(1,num):
    print(i)
    x=[2,3,4,5]
    print(x[num])
    break
    except IndexError :
    print("IndexError")
    box.append(IndexError)
    except ValueError:
    print("ValueError: input a number beta")
    box.append(ValueError)
    for xm in box:
    print(xm)

  • @technologymad9253
    @technologymad9253 ปีที่แล้ว +71

    CodeWithHarry please add some quizes and practice sets also in the course as you always do. So that we can practice that concepts we learned. And also make some sort of project after 30 days so that we can gain some confidence. Hope it will help.

  • @dxdelvin
    @dxdelvin ปีที่แล้ว +68

    BY CHATGPT:
    There are several types of errors that can occur in Python:
    Syntax errors: These occur when the code is not written in a proper format, and the interpreter is unable to understand it. For example, if you forget to close a parentheses or forget to indent code properly, you will get a syntax error.
    Name errors: These occur when you try to use a variable that has not been defined.
    Type errors: These occur when you try to perform an operation on a value of the wrong type. For example, if you try to add a string and a number, you will get a type error.
    Index errors: These occur when you try to access an element in a list or a string using an index that is out of bounds.
    Value errors: These occur when a built-in function receives an argument of the right type, but an inappropriate value.
    Attribute errors: These occur when you try to access an attribute of an object that does not exist.
    Import errors: These occur when you try to import a module that does not exist or cannot be found.
    Key errors: These occur when you try to access a dictionary with a key that does not exist.
    File not found errors: These occur when you try to open a file that does not exist or cannot be found.
    Indentation errors: These occur when the indentation of the code is not consistent, which can cause the interpreter to behave unexpectedly.
    Zero division errors: These occur when you try to divide a number by zero, which is not allowed in Python.
    Recursion errors: These occur when a function calls itself recursively, but the base case is not defined, causing the function to call itself indefinitely.
    Memory errors: These occur when the program tries to use more memory than the computer has available.
    Overflow errors: These occur when a calculation produces a result that is too large to be stored in the allocated memory.
    Underflow errors: These occur when a calculation produces a result that is too small to be represented accurately in the allocated memory.
    Assertion errors: These occur when an assert statement fails.
    Not implemented errors: These occur when a method or function has not been implemented yet.
    Runtime errors: These occur while the program is running and can be caused by a variety of factors, such as invalid input, missing resources, or other unforeseen circumstances.
    Security errors: These occur when the program tries to perform an action that is not allowed due to security restrictions.
    Timeout errors: These occur when a program takes too long to run and exceeds the allotted time limit.
    Unbound local errors: These occur when you try to access a local variable before it has been defined.
    Internal errors: These occur when the interpreter encounters an unexpected condition that it cannot handle.
    External errors: These occur when the program interacts with an external resource (such as a database or a network connection) and something goes wrong.
    It is also worth noting that Python allows you to define your own custom errors using the Exception class. This can be useful if you want to create specific error handling logic for your program.

    • @pratikanand8437
      @pratikanand8437 ปีที่แล้ว +4

      thank you so much

    • @brlb18
      @brlb18 9 หลายเดือนก่อน

      Thnx lot

    • @SarcasmWEB
      @SarcasmWEB 4 หลายเดือนก่อน

      For someone who is beginner or intermediate, => except exception as e:
      This line would save a lot of worries incase you are unsure which error you want to consider in the except block.

    • @Mohiddinshareef
      @Mohiddinshareef 3 หลายเดือนก่อน

      thanks very useful info

  • @mohdrayees8919
    @mohdrayees8919 ปีที่แล้ว +10

    hello sir, i have tried this one:
    try:
    tup1 = (1,2,3,4,5)
    tup1.insert(2,9)
    print(tup1)
    # list1 = list(tup1)
    # list1.insert(2,9)
    # tup1 = tuple(list1)
    # print(tup1)
    except AttributeError :
    print("No changes can be made in a tuple directly, Once they are created")
    also this one:
    try:
    dict = {"name": "rayees", "age": 23, "roll.No.": "17e31a0333", "DOB":"23/07/1999"}
    # print(dict["name"])
    print(dict["adhaar"])
    except KeyError:
    print("This key do not exist in dict")
    Thank you so much harry sir

  • @khemchand494
    @khemchand494 ปีที่แล้ว +5

    If you are trying to run a python program and there are chances of getting errors, then we can handle those errors using try-exception technique. We can use try keyword and can write your block of code inside the try with proper indentation and then, we have to use except keyword and then we can anything that we want to happen with the program exceution whenenver the error occurs. We can also specify the types of error with except keyword like index error, value error and can write the body that we want to excute upon error occuring.

  • @reality7046
    @reality7046 ปีที่แล้ว +8

    🥳🥳🥳 nice concept , with this we can get error in the middle of code printed and check for further code's correctness after that also kind a substitute for commenting above code or doing pass 😀

  • @harshitagupta5372
    @harshitagupta5372 5 หลายเดือนก่อน

    Thanks Harry
    num=input("Enter the number to print table:")
    try:
    for i in range(1, 11):
    print(f'{int(num)}*{i}={i*int(num)}')
    except ValueError:
    print(f'Invalid input your input is {num} expecting number')

  • @eashovon
    @eashovon ปีที่แล้ว +1

    Present from Bangladesh Brother. After 6 days of busyness, I am back to this course... #Day36 Done

  • @deepakkumar-bf7cr
    @deepakkumar-bf7cr ปีที่แล้ว +5

    Thanks for giving this series Harry bhi
    Please start practice series in python

  • @bibeksamal5300
    @bibeksamal5300 ปีที่แล้ว +2

    #36 completed
    Love code with Harry 3000❤️

  • @punyamsingh
    @punyamsingh ปีที่แล้ว +14

    please resume ML with Python video series 😭😭 really really need that

  • @__ayu
    @__ayu ปีที่แล้ว +3

    #DAY36 COMPLETED
    THANK YOU #CodeWithHarry

  • @arpankarmakar16
    @arpankarmakar16 ปีที่แล้ว +7

    Present on Day #36th

  • @AshmitaJ-e6h
    @AshmitaJ-e6h 8 หลายเดือนก่อน

    present sir ji today also....... Thank you sooo sooo sooo much sirji to teach us the valuable things for free....... god bless you with the best best bestest always in your life...... keep it up sirji,...... help us always like this........ huge huge huge respect for you......🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏

  • @avijitdey6998
    @avijitdey6998 ปีที่แล้ว +4

    please make more detailed videos on exeption handling

  • @Studypoint1915
    @Studypoint1915 ปีที่แล้ว +2

    u never disappoint ,, i always understand your teachings

  • @zubairahmad6623
    @zubairahmad6623 ปีที่แล้ว +5

    Harry bhai... 😍😍😍
    You are great🙏🏻

  • @technikalproblem6780
    @technikalproblem6780 ปีที่แล้ว +3

    Thank you so much sir for creating this video!

  • @Sumit_Jethuri
    @Sumit_Jethuri 9 หลายเดือนก่อน

    Hi Harry,
    I loved your course. Extremely helpful.
    Could you please share full notes in a PDF which might help us in the revision time.
    Thanks

  • @abdulhannan.018
    @abdulhannan.018 ปีที่แล้ว

    a = input("Enter a: ")
    try:
    for i in range(1,11):
    print(f"{int(a)} x {i} = {int(a)*i}")
    except Exception as error:
    print(error)

  • @satyampandey-fx8gz
    @satyampandey-fx8gz ปีที่แล้ว +2

    #day36 consistency maintain
    20:11 2/1/2023

  • @jatinbhatt2222
    @jatinbhatt2222 ปีที่แล้ว +3

    Present Sir on Day-36 ✋

  • @abdullahbinshahzad
    @abdullahbinshahzad ปีที่แล้ว +1

    The main thing is missing that we don't know what type of exceptions exist
    I try this as a exepction handle:
    def run():
    name=input("Enter a valid string otherwise error recieved until you enter the string :")
    try:
    hi=int(name)
    except ValueError as e:
    print(e)
    run()
    run()

  • @Lokesh_arya_361
    @Lokesh_arya_361 ปีที่แล้ว +3

    Brother at time1:39 why you use f outside string I didn't get it ?

  • @RomaisaIrshad-b7u
    @RomaisaIrshad-b7u 4 หลายเดือนก่อน +1

    Harry bahi is very good programer

  • @JoyBoy_013
    @JoyBoy_013 ปีที่แล้ว +1

    Proud to learn python with you Harry bhai

  • @vipulyadav2144
    @vipulyadav2144 7 หลายเดือนก่อน

    after 1 month i continuing my day 35,36 video .
    i enjoying this course too much.

  • @GoGetSP
    @GoGetSP 5 หลายเดือนก่อน

    at 2:14
    for i in range(1,11):
    print(f"{a} X {i}= {a*i}")
    why is the output like?
    7,77,777,777 ?
    How is that generated? Please explain the logic. Thankyou.

  • @justtt.prerna
    @justtt.prerna 10 หลายเดือนก่อน

    def multiplication():
    try :
    num = int(input("Enter the number : "))
    print(f"Multiplication table for {num}:")
    for i in range (1, 11):
    result = num * i
    print(f"{num} x {i} = {result}")
    except ValueError :
    print("ERROR : Enter valid number !")
    except Exception as e :
    print(f"An unexpected error occured : {e}")
    finally :
    print("Execution is fully completed")

    multiplication()

  • @rishabhdhoni
    @rishabhdhoni ปีที่แล้ว +1

    Hii Harry bhai

  • @hamzazaman5677
    @hamzazaman5677 ปีที่แล้ว +1

    Hello Harry Bhai, Plz make a Video on "'Subprocess Module" and other stuff related to that e.g PIPE, STDIN, STDOUT etc. thank You!

  • @mariamhasan3733
    @mariamhasan3733 ปีที่แล้ว +1

    Day #36 completed!

  • @LASTSTRANGER
    @LASTSTRANGER ปีที่แล้ว +2

    Present Sir, #Day_8 !!!

  • @anonymous____________________4
    @anonymous____________________4 ปีที่แล้ว

    Pranam bhrata 🙏 apka bahutt baht dhanyawad🙏😍😇❤️

  • @bepositive271
    @bepositive271 ปีที่แล้ว

    sir mai pahle error ko isdigit() se solve karta tha
    par ye to nwe scheme pata chali
    thanks sir itna kuch sikhnaa ke liye

  • @killerdestiny786
    @killerdestiny786 7 หลายเดือนก่อน

    I was trying (try and except) after error it should go back to input again rerun the programme. so I wrote this
    a= 0
    while a == int(a):
    try:
    a= int(input("Enter the number : "))
    print(f"Multiplication table of {a} is : ")
    for i in range(1,11):
    print(f"{int(a)} x {i} = {int(a)*i}")
    break
    except:
    print("Invalid input")

  • @thatcoolkid370
    @thatcoolkid370 ปีที่แล้ว +1

    Day #36 in 100DaysOfCode. Enjoying this advanced concepts

  • @NEERAJ-dw9bt
    @NEERAJ-dw9bt 9 หลายเดือนก่อน +1

    Present sir 🤚

  • @sakshamraj7872
    @sakshamraj7872 ปีที่แล้ว +6

    # I have a problem.
    for i in range (1,11):
    try:g = int(input(f"Enter your guess.Its your chance no-{i}
    >>"))
    except:break
    if g == n :
    print(f"You guessed right number,which is {n} in chance no {i}.")
    break
    elif g < n:
    print("You guessed too low number.")
    elif g > n:
    print("You guessed too high number.")
    if i ==10:
    print(f"You lost!
    You couldn't guess the right number which was {n}.")
    #Mujhe es code ke except wale part me loop break karne ke sath sath kuch print v karna h kaise kara😢

    • @sudhansubalasahoo
      @sudhansubalasahoo ปีที่แล้ว

      Try this:
      n = 5
      for i in range(1, 11):
      try:
      g = int(input(f"Enter your guess.Its your chance no-{i}
      >>"))
      except:
      print("Input is not an integer.")
      break
      if g == n:
      print(f"You guessed right number,which is {n} in chance no {i}.")
      break
      elif g < n:
      print("You guessed too low number.")
      elif g > n:
      print("You guessed too high number.")
      if i == 10:
      print(f"You lost!
      You couldn't guess the right number which was {n}.")
      Just print the statement above the break

    • @shubhamsaini4871
      @shubhamsaini4871 ปีที่แล้ว +1

      Break ke upar wo line write karo

    • @sakshamraj7872
      @sakshamraj7872 ปีที่แล้ว +1

      @@sudhansubalasahoo Try keya but kam nahi keya

    • @sudhansubalasahoo
      @sudhansubalasahoo ปีที่แล้ว

      @@sakshamraj7872 I tried and it works

    • @sakshamraj7872
      @sakshamraj7872 ปีที่แล้ว +1

      @UC9qKbi_i7REYB5uk3xozWcg Thanks! Ye kam kar gaya mene .
      except: print("This is not integer.")
      break
      ase lekha tha esleya error aya tha
      except:
      print("This is not integer.")
      break
      lekin ase lekne se kam chalgaya

  • @MD.HABIBURRAHMANHABIB-l1t
    @MD.HABIBURRAHMANHABIB-l1t วันที่ผ่านมา

    thank you brother

  • @Iamsae
    @Iamsae ปีที่แล้ว +261

    "Tired Of CodingNinja Ads On Harry Bhai Videos" Raised a Hand ✋️

    • @pranshu2op
      @pranshu2op ปีที่แล้ว +20

      I am ad vanced

    • @stickstockpepe1414
      @stickstockpepe1414 ปีที่แล้ว +1

      Me 2

    • @Iamsae
      @Iamsae ปีที่แล้ว +6

      @@superhitragini once upon a Time, I'm Also User Of Vanced🍭

    • @shubhajitchakraborty
      @shubhajitchakraborty ปีที่แล้ว +10

      @@superhitragini You are using it for your benefits, but Harry bhai doesn't charge us a single penny for his courses, advertisement is the only way he can earn from. Don't use vanced or any other mod apps. It also breaches your privacy. Hope you understand.

    • @_iBad
      @_iBad ปีที่แล้ว

      @@shubhajitchakraborty No? 🤣

  • @Pythongirl_
    @Pythongirl_ ปีที่แล้ว +1

    I already reached to 58 days and using both video to create this code below:
    Question:
    # Person Class:
    # Create a Person class with attributes like name, age, and country.
    # Initialize these attributes using the __init__ method and display them using a method like display_info.
    class people:
    def __init__(self,name,age,country):
    self.name = name
    self.age =age
    self.country = country
    def info(self):
    print( f'Your name is {self.name} and you are {self.age} years old.You are from {self.country}' )
    name = input('Enter your name: ')
    try:
    age = int(input('Enter your age: '))
    except(ValueError):
    print('The age should be in an integer')
    exit()
    country = input('Enter your country: ')
    user_input = people(name,age,country)
    user_input.info()

  • @ImtiazAli-h1r
    @ImtiazAli-h1r หลายเดือนก่อน

    this man is amazing, I love it

  • @lakhyadeepsen
    @lakhyadeepsen ปีที่แล้ว +2

    Day 36 of 100 of python challenge completed. #100DaysofCode #100dayspythonchallenge

  • @SumitBudhawant
    @SumitBudhawant 9 วันที่ผ่านมา

    Thank you so much!

  • @mohi876
    @mohi876 ปีที่แล้ว +1

    Hi Harry, Have u ever tried for bug bounty hunting in ur life out of curiosity? What was your experience? Did u find it too hard?

  • @AI_Generates
    @AI_Generates ปีที่แล้ว

    Bhai explurger app kaise bana uski kitni team hai and konsi programming language use krta hai and konsa server use krta hai or development me kitna spend hua hoga pr ek video bnao please

  • @RomaisaIrshad-b7u
    @RomaisaIrshad-b7u 4 หลายเดือนก่อน

    35 course are very good

  • @CoderzGaming093
    @CoderzGaming093 ปีที่แล้ว +1

    #day36 love you harry bro you are really genius bro💖💖💝

  • @statusmaster5759
    @statusmaster5759 ปีที่แล้ว

    Bhai aapko all MacBook ko compare karke kiske liye konsa best h video bana kar suggest krna cahiye 🤔🤔🤔

  • @yatindrapabbati6878
    @yatindrapabbati6878 ปีที่แล้ว +1

    DAY36-PRESENT SIR!

  • @biswajeet9826
    @biswajeet9826 4 หลายเดือนก่อน

    Greak work !!
    Thanks a lot !!

  • @junaidtanveer7191
    @junaidtanveer7191 ปีที่แล้ว

    kamal harry bhai

  • @shauryasaxena2406
    @shauryasaxena2406 ปีที่แล้ว

    HARRY SIR PLEASE COURSE KE END MEIN KOI TEST YA EXAM LEKE CERTIFICATION PROVIDE KARDIJIYE....DESPERATELY NEED THAT...PLEASE ALSO GIVE REGULAR PRACTICE SETS OF OLD CONCEPTS AS REVISION

  • @GratefulGoutam
    @GratefulGoutam ปีที่แล้ว +1

    You vibe amazing man!!

  • @sanketkulshrestha
    @sanketkulshrestha ปีที่แล้ว +1

    Bhai meri marzi, mera keyboard... 2:47 😂🤣

  • @SY2023yashi
    @SY2023yashi ปีที่แล้ว

    Harry bhai great teacthing style.

  • @himanshuraivines9551
    @himanshuraivines9551 ปีที่แล้ว

    Harry bhai kal aur aj ka video ek no tha bhai 🙏🙏❤️

  • @codingchronicle
    @codingchronicle ปีที่แล้ว

    Present bhai

  • @DevjitisLiveOfficial
    @DevjitisLiveOfficial ปีที่แล้ว

    Wahhh Thumbnail OP HAI

  • @AnkitGupta-s2h
    @AnkitGupta-s2h 8 หลายเดือนก่อน

    Syntax
    try:
    except:
    or
    except name:
    We can use many except as required

  • @RajNamdev_19
    @RajNamdev_19 ปีที่แล้ว +1

    LOVE YOU HARRY BHAI❤

  • @ahem2784
    @ahem2784 ปีที่แล้ว

    Thanks for try and except codes for python

  • @manishsakyawal1808
    @manishsakyawal1808 ปีที่แล้ว +1

    Harry sir, may you make a new course on spring boot api using java

  • @rohankulkarni5657
    @rohankulkarni5657 ปีที่แล้ว

    nice video
    it is same like java try and catch block

  • @khajamohiddinshaik4449
    @khajamohiddinshaik4449 2 หลายเดือนก่อน

    thank you

  • @niteshch9166
    @niteshch9166 ปีที่แล้ว

    Present Harry Sir!

  • @Bhoot-Bang-ak
    @Bhoot-Bang-ak ปีที่แล้ว +1

    sir i am waiting for this topic . I do mistake . i understood this concept 🖐🖐

  • @ahsantariq3926
    @ahsantariq3926 ปีที่แล้ว

    Thanks, Harry Bhai

  • @siddusriram4871
    @siddusriram4871 3 หลายเดือนก่อน +1

    How does Python know which "Except" to get into? Are the types of errors and their "except" already predefined?

  • @gamex9553
    @gamex9553 ปีที่แล้ว

    Day 36 completed.

  • @notknown84
    @notknown84 ปีที่แล้ว +1

    Sir can we have a detailed course on dbms please

  • @vjournalbytej9832
    @vjournalbytej9832 10 หลายเดือนก่อน

    Present Sir 🤚

  • @Nightmare-rc6lk
    @Nightmare-rc6lk 11 หลายเดือนก่อน

    thanks man

  • @adityapradhan8474
    @adityapradhan8474 ปีที่แล้ว +3

    I wonder why python is so damn simple as compared to Java yo

  • @InsaaniatDost
    @InsaaniatDost ปีที่แล้ว

    hello bro🌹
    can we convert a wordpress website into a python programming????
    just like we change formate of a picture or video in other formate......💭💥💭💥💭💥💭💥

  • @harsh-alashi
    @harsh-alashi ปีที่แล้ว

    Nice

  • @mdsohanurrahmanhridoy1343
    @mdsohanurrahmanhridoy1343 ปีที่แล้ว +1

    #Completed DAY#36 😍

    • @onlysahil
      @onlysahil ปีที่แล้ว

      How was your experience then? And how much coding did you learned in phyton...... Can you just share ? And he said 100 days but there is only 36 days?

    • @mdsohanurrahmanhridoy1343
      @mdsohanurrahmanhridoy1343 ปีที่แล้ว

      @@onlysahil Vai 100 days hi hoga....aj 36 day chal raha hain...ab tak bohut accha future main to dhamal hoga...

  • @RohanDasRD
    @RohanDasRD ปีที่แล้ว

    Day 36 Done

  • @atulyadav993
    @atulyadav993 ปีที่แล้ว

    Best sir

  • @enciridus2291
    @enciridus2291 ปีที่แล้ว +1

    Harry vai first comment big fan sir

  • @meditationmusic6482
    @meditationmusic6482 ปีที่แล้ว

    Thanks sir.

  • @simple3688
    @simple3688 ปีที่แล้ว +1

    🤞

  • @L0iving0
    @L0iving0 ปีที่แล้ว +7

    Hello Harry bhai
    I'm in class 11 & I want To become Python Software Developer so should I need to do BCA or BTech
    PLEASE Answer

  • @Manish-qt1bz
    @Manish-qt1bz ปีที่แล้ว

    Present Sir 🔥

  • @chandar_Kumar
    @chandar_Kumar ปีที่แล้ว

    Day36.. Present Sir

  • @LegXgodGaming
    @LegXgodGaming ปีที่แล้ว +1

    Type of error next plz

  • @rakeshchaudhary5690
    @rakeshchaudhary5690 ปีที่แล้ว +1

    Brother make a video on how to update react js and node js code on already hosted sites on cpanel hosting.

  • @ApniGardening7
    @ApniGardening7 ปีที่แล้ว +1

    bro pls pls make a video on how to make raycast engine in python

  • @Radhe_radhe2929
    @Radhe_radhe2929 ปีที่แล้ว

    Day 36 🔥

  • @daywithkunnuandaarav
    @daywithkunnuandaarav ปีที่แล้ว +1

    Hlw bro I m mechanical graduate 2020 and now 2023 i am learning python . So can I start with as a carier of software engineer .
    What is the right path?

  • @haldermosai3048
    @haldermosai3048 ปีที่แล้ว

    Yes bro

  • @deekshithaparasu
    @deekshithaparasu ปีที่แล้ว

    #day36 completed

  • @codewithdhairya1193
    @codewithdhairya1193 ปีที่แล้ว +1

    very good explanation👍👍👍👍

  • @ramvachanbhagwaan
    @ramvachanbhagwaan ปีที่แล้ว

    Game development full course please

  • @AmitPandey-sr9fl
    @AmitPandey-sr9fl ปีที่แล้ว

    Day 36 done sir

  • @ParasKumar-fk4su
    @ParasKumar-fk4su ปีที่แล้ว

    thankyou

  • @dharvikop
    @dharvikop ปีที่แล้ว

    Day 36 done