Help on functions 19!


Oops, try again. Your function seems to fail on input True when it returned '1' instead of 'Nope

I expected the code to behave. Just kidding i wanted the function distance_from_zero to workout the absolute value of a data type as long as it is a integer or a float.

def distance_from_zero(DFZ):
    if type(DFZ) == int or float:
        return abs(DFZ)
        return 'Nope'


Hi @betajumper03616 ,

The or operator takes two operands. One of the operands in the expression that you wrote is type(DFZ) == int. The other is simply, float. That might not be what you intended.


i was doing so well on my own and troubleshooting my own errors until now. Haha thankyou !


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.