-3
print(True or 5 / 0 > 3)

This is my code but it returns True

Is there a reason why it doesn't return a Zero Division Error?

g0rdonL
  • 301
  • 1
  • 3
  • 14

1 Answers1

0

Its because True is always true. The Python interpreter does not evaluate the right side of the or operator in this case, because the outcome of an or expression is always true if one of its operands is true. If you enter5 / 0 > 3 or True than you get your devision by zero error

maxE
  • 359
  • 1
  • 11