19/19 Help


#1

This is what I've done:

def distance_from_zero(zero):
if type(zero) == int or type(zero) == float:
return abs(zero)
else:
return "Nope"

Can anyone tell me what I did wrong and what I should have done?


#2

In what way is it not acting like you want? And what does does your code really look like? Mind the formatting.


#3

Try out the identation.

def distance_from_zero(n):
    if type(n) ==int or type(n) == float:
        return abs (n)
    else:
        return "Nope"

#4

please help me on 5/19 Functions Calling Functions


#6

So why can't I also get a correct response using the following code?

def distance_from_zero(x):
    if type(x) == str:
        return "Nope"
    else:
        return abs(x)

#7

def distance_from_zero(n):

if type(n) == int or type(n) == float:
    return abs(n)
else:
    return "Nope"

Worked for me. it was about formatting. Add the required 4 spaces before if and return :smile:


#8

This is what worked for me. Make sure the spaces in your if statement are correct or you may return an error. Good luck.


#9

hi, can someone please tell me what i am doing wrong? this is my code:

def distance_from_zero(n):

** if type(n) == int or type(n) == float:**

** return abs()**


** else:**
** return 'nope'**

and the error message down below is:

Ops, tente outra vez.
** It looks like you have a TypeError. Make sure your function should **
only take one input. (Or check the error message for more info.) - abs()
** takes exactly one argument (0 given)**


#10

sorry let me rewrite that

hi, can someone please tell me what i am doing wrong? this is my code:

*def distance_from_zero(n):

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

    return abs()

else:
    return 'nope'*

and the error message down below is:

  • Ops, tente outra vez.
    It looks like you have a TypeError. Make sure your function should
    only take one input. (Or check the error message for more info.) - abs()
    takes exactly one argument (0 given) *

#11

I'm just learning too, but I'm pretty sure you missed the argument in abs().
Try abs(n)