[PYTHON] Error divided by 0 Handling of ZeroDivisionError


    number1 = 200
    number2 = 0
    answer = number1 / number2
except ZeroDivisionError as e:


Execution result

division by zero

When an exception occurs in the try block, The object representing the exception is assigned to the variable e.

If an exception occurs inside the try block Then interrupt the process Execute the code of the except block.

After exception handling The code you definitely want to execute is Describe in the finally block.

Recommended Posts

Error divided by 0 Handling of ZeroDivisionError
Error divided by 0 Processing of ZeroDivisionError 2
Mainframe error handling
Python Error Handling
SikuliX error handling
django.db.migrations.exceptions.InconsistentMigrationHistory error handling
Summary of error handling methods when installing TensorFlow (2)
About tweepy error handling
[Fan control] Initial setting of fancontorl and error handling
Error handling in PythonBox
GraphQL (gqlgen) error handling
Around feedparser error handling
Error handling after stopping the download of learned data of VGG16
OSX MySQL-python 1.2.5 error handling IndexError: string index out of range
[Error countermeasures] django-heroku installation error handling
Error handling when installing mecab-python
About FastAPI ~ Endpoint error handling ~
Handling of absolute paths of os.path.join
Handling of quotes in [bash]
Exception handling using Python's ZeroDivisionError
Visualization of data by prefecture
python> Handling of 2D arrays
Handling of python on mac
Calculation of similarity by MinHash
PyCUDA build error handling memorandum
[Python of Hikari-] Chapter 07-02 Exception handling (continuous execution of the program by exception handling)