+ 1
Why doesnt this run? for i in range (0,20,2): num1 = i try: num2 = 0 print (num1 / num2) print("Done calculation") except ZeroDivisionError: print("An error occurred") print("due to zero division")
9 Answers
+ 6
Actually your program start with both num1 and num2 = 0 and it will only run once and generate those two errors
An error occurred
due to zero division
+ 4
Your code gets ZeroDivisionError every time because num2 is assigned 0 before each division. Is that..?
+ 1
your indentation should be incorrect in the actual code you are trying to run
+ 1
Yes it worked.
except ZeroDivisionError as err:
print(str(err))
What did you do there?
0
I get the Taberror at the line after "try:"
0
which editor you are using?
0
Im using the code playground of this app.
Identation is the same used above.
0
This program will run and it will print the statements in except block for every iteration in for loop because division is always done by num2 which is assigned to zero every iteration
- 3
Search my code named " pawan kumar reddy" in playground & u will get the answer