$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #179

Which fix removes the bug?

def divide(a, b):
    return a / b
print(divide(4, 0))
  1. Guard against zero b
  2. Cast both to floats
  3. Return None on error
  4. Use // instead of /
Division by zero raises ZeroDivisionError; the caller needs a checked path.
Play Problem Solving ▸