The code is correct, but the execution is faulty

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Jackli
Posts: 80
Joined: Thu Apr 29, 2021 9:11 am

The code is correct, but the execution is faulty

Post by Jackli » Thu Jul 29, 2021 8:53 am

The following code I wrote without an error being reported, but when it was executed an error occurred.

Code: Select all

>>> a = 10/0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: The code is correct, but the execution is faulty

Post by stijn » Thu Jul 29, 2021 9:16 am

What would you expect the result to be? It's pretty much undefined, hence the error.. https://en.wikipedia.org/wiki/Division_by_zero

williamhenrick
Posts: 16
Joined: Wed Jul 14, 2021 8:58 am

Re: The code is correct, but the execution is faulty

Post by williamhenrick » Sat Jul 31, 2021 4:47 pm

obviously it will give the error, btw check 20/0, that will also give the error. :D

Post Reply