Learning Center
Learning Center
  • HTML
  • CSS
  • JAVASCRIPT
  • Bootstrap
  • React
  • jQuery
  • NodeJs
  • Sql
  • MySql
  • Python
  • OpenVPN Setup
  • Log In
Coding Choice Home About Contact ☰

  1. You are here
  2. Home
  3. python
  4. exception_handling

Sidebar
  • Introduction
  • Python Basics
  • Data Structures in Python
  • Functions and Modules
  • Object-Oriented Programming
  • File Handling
  • Exception Handling
  • Advanced Python Concepts
  • Working with Databases
  • Web Development with Python
  • Email Client with Python
  • Data Science with Python
  • Machine Learning with Python
  • Automation with Python
  • Testing in Python
  • Deployment and Best Practices
  • Share via
    • Share via...
    • Twitter
    • LinkedIn
    • Facebook
    • Pinterest
    • Telegram
    • WhatsApp
    • Yammer
    • Reddit
    • Teams
  • Send via e-Mail
  • Print
  • Permalink

Exception Handling

Exception handling in Python is done using try, except, and finally.

Example:

try:
    num = 10 / 0
except ZeroDivisionError:
    print("Cannot divide by zero!")
finally:
    print("This will always execute.")

Output:

Cannot divide by zero!
This will always execute.