Starlit Daily

📚 › Python: the friendliest first language

13. Handling errors with try and except

इस लेख का अनुवाद अपने आप होगा। अभी अंग्रेज़ी में दिखाया जा रहा है।

try runs code that might fail, and except handles the error. Without it, a single mistake stops the whole program.

Read the error message: it names the problem and the line.

उदाहरण देखें

try:
    print(10 / 0)
except ZeroDivisionError:
    print("Cannot divide by zero")

✍️ अब आपकी बारी

Use try and except: in try divide 1 by 0, in except print Cannot divide.

← कोर्स पर वापस