Python error "ZeroDivisionError: division by zero"

0 votes

I'm getting the following error while executing a python code:

ZeroDivisionError: division by zero
In [55]:

x = 0
y = 0
z = x/y
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-55-30b5d8268cca> in <module>()
      1 x = 0
      2 y = 0
----> 3 z = x/y

ZeroDivisionError: division by zero
May 31 in Python by Yamini
178 views

1 answer to this question.

0 votes

Catch the error and handle it:

try:
    z = x / y
except ZeroDivisionError:
    z = 0
answered May 31 by Rhea

Related Questions In Python

+1 vote
1 answer

Python error "ZeroDivisionError: float division by zero"

remove the following statements from code     ...READ MORE

answered Nov 12 in Python by Abhishek
• 150 points
506 views
+2 votes
2 answers

Error while printing hello world in python.

You must be trying this command in ...READ MORE

answered Mar 31, 2018 in Python by GandalfDwhite
• 1,320 points
141 views
0 votes
1 answer

Number division in python

For Python 3, use the // operator: q = ...READ MORE

answered Apr 18, 2018 in Python by Nietzsche's daemon
• 4,260 points
41 views
+1 vote
3 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 399 views
+4 votes
6 answers
0 votes
1 answer

When I create and remove files rapidly on windows using python I get WindowsError (Error 5)

Here's the short answer: disable any antivirus or ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,720 points
209 views
0 votes
11 answers