![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to handle python exception inside if statement?
The code can be written as follows to catch the exception
a, b=5, 0 try: if b != 0: print a/b else: a/b raise ZeroDivisionError except Exception as e: print e
We get the following output
C:/Users/TutorialsPoint1/~.py integer division or modulo by zero
Advertisements