Functions question


#1



File "python", line 6
SyntaxError: 'return' outside function


I am not sure why this code isn't running. Can someone help please?


`python

import math

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

'


#2

What are you trying to do with return type(n)?


#3

I'm not sure what it should be returning?


#4

Your function does nothing, if it returns type(n) at the beginning. Function ends always to the return- statement, and in your case it is at the beginning so the function ravels up.


#5

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