Review Built in functions


#1

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

^whats wrong with this code?It says--

File "python", line 2
if type(a)==int or type(a)==float:
^
IndentationError: expected an indented block

Please help me out.I faced this indentation error alot in earlier lessons as well.Thankyou :slight_smile:


#2

Can you post a screen shot of your code because the forum has an issue with printing code with correct indentation. However you might running that if statement outside of the function or too far in it.

P.S. remove the quotes("") from the return statement of the absolute value.


#3

HI like the error says
IndentationError: expected an indented block
you should indent the if and else statement inside the function


#4

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