Review: Built-In Functions


#1

Hi,

I’m a bit curious on the function lesson 19/19 on the “Review: Built-In Functions”
I create exactly as the solution build, but it doesn’t work. it says
"
File “python”, line 11
return abs(s)
^
IndentationError: expected an indented block
"

This is the code

#this one is the solution
def distance_from_zero(num):
if type(num) == int or type(num) == float:
return abs(num)
else:
return “Nope”

#this one I create myself
def distance_from_zero(s):
if type(s) == int or type(s) == float:
return abs(s)
else:
return “Nope”

can someone tell me what did I do wrong?


#2

probably mixing tabs with spaces (which doesn’t show in your screenshot and the text you posted is missing indentation altogether - code needs to be copied exactly or you’re sharing something else)


#3

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