$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · medium · #62

Which fix removes the bug?

def rate(a, b):
    if b is 0:
        return 0
    return a / b
  1. Compare by value with if b == 0:
  2. Compare by value with if b = 0:
  3. Change the guard to if not b is 0:
  4. Return None instead of 0 when empty
is compares identity, not value; use == for numeric comparison.
Play Problem Solving ▸