#19: distance_from 0


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/python-beginner-c7VZg/4/3?curriculum_id=4f89dab3d788890003000096#

<In what way does your code behave incorrectly? Include ALL error messages.>

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

<What do you expect to happen instead?>
Return “Nope”

```python

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

<do not remove the three backticks above>

#2

Hi @rubyjumper45925,

Instead of this …

    if type(num) == int or float:

… you need to have this in order to test whether type(num) is either equivalent to int or is equivalent to float

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

#3

Thank you! Much appreciated. However now I am getting a totally different error message:

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

Returns error: Your function seems to fail on input True when it returned ‘None’ instead of ‘Nope’


#4

In the else block, you have only …

        "Nope"

Without a return statement, it will return the value, None.

It should be …

        return "Nope"

#5

Thanks so much, im an idiot


#6