Why it keep return 1?


#1

In 19/19

distance_from_zero(num):
if type(num) == int or float:
return abs(num)
else:
return “Nope”

print distance_from_zero(True) #this should return Nope, but instead, it returns 1


#2
>>> print (float)
<class 'float'>
>>> print (float and True)
True
>>> 

That tells us that float evaluates to True, or, is truthy.

Any condition OR truthy expression will yield True.