That's because of Python's duck typing – bool is a subclass of int.
bool
int
print(False == 0 and True == 1) # Prints "True"
And since the description asks to return 0 when the numbers are equal and False is equivalent to 0, this is acceptable.
0
False
well, that'd be pretty anti-pythonic, tho... ;)
but false extending 0, if the expected answer is 0, that's still correct.
proof: this passes this fixed test: test.assert_equals(close_compare(5, 5), 0)
test.assert_equals(close_compare(5, 5), 0)
Loading collection data...
That's because of Python's duck typing –
bool
is a subclass ofint
.And since the description asks to return
0
when the numbers are equal andFalse
is equivalent to0
, this is acceptable.well, that'd be pretty anti-pythonic, tho... ;)
but false extending
0
, if the expected answer is 0, that's still correct.proof: this passes this fixed test:
test.assert_equals(close_compare(5, 5), 0)