Your function seems to fail on input -10 when it returned <'type 'int>' instead of '10'

I expect the code to return abs

```
def distance_from_zero(num):
if type(10):
return type(10)
else:
print "Nope"
```

Your function seems to fail on input -10 when it returned <'type 'int>' instead of '10'

I expect the code to return abs

```
def distance_from_zero(num):
if type(10):
return type(10)
else:
print "Nope"
```

the directions say "If the type of the argument is either int or float, the function should return the absolute value of the function input."

So you will have to use:

"if type(num) == int or type(num) == float:"

Then after that, you tell it what to do, which is to return the number's absolute value:

"return abs(num)"

I did exactly what the instructions stated and it stills gives me an error message:

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

this is my code now

def distance_from_zero(num):

if type(num) == int or type(num) == float:

return abs(num)

```
else:
print "Nope"
```

I did exactly what the instructions stated and it stills gives me an error message:

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

this is my code now

def distance_from_zero(num):

if type(num) == int or type(num) == float:

return abs(num)

else:

print "Nope"

The fact that one case *returns* a value, implies that the other case should, as well.

`return "Nope"`

The function was exited with no return value (print "..." is not returned) so Python responds with `None`

. See the difference?

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