Which fix removes the bug?
def rate(a, b):
if b is 0:
return 0
return a / b
- Compare by value with
if b == 0: - Compare by value with
if b = 0: - Change the guard to
if not b is 0: - Return
Noneinstead of 0 when empty
is compares identity, not value; use == for numeric comparison.