Built in functions 19/19 - indented but i get an error

def distance_from_zero(num):
	if type(num) == int or type(num) == float:
  	return abs(num)

Gets me this error in the console:

File “python”, line 3
return abs(num)
IndentationError: expected an indented block


That’s weird, this image actually shows my code, but when i pasted it onto the forum it doesn’t look indented as well. Does anyone here have any idea why this happens?


Remove any indentation on your code and put them again using only tabs or spaces, don’t mix them.

Everything related to your code logic is fine.


The Python interpreter does not take kindly to code that mixes tabs and spaces for indentation.

Different environments are free to use different amounts of space to represent tabs. As a result, when you mix tabs and spaces, the indentation might look correct in the console, and not appear the same when posted. That is the case with your code.

As @kingdarboja suggested, you need to redo all of your indentation. In the Codecademy editor, it is best to use spaces and no tabs for indentation.


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