19.review;built in functions


Example worked. But not sure why is it not returned any values on the console? Guys! any idea?

def distance_from_zero(num):

if type(num) == int:
return abs(num)
elif type(num) == float:
return abs(num)
return "Nope"



There won't be a print out unless your print the return value.

print distance_from_zero(-25)


Nicely done!
Worked for a string as an argument, too!



Tried this after seeing the examples here, but keeping what i had made already, i got a pass by doing this;

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

Was necessary to use "print" ?


Good question. I have that quest also. Please somebody help!


Can't say for sure without a link to the exercise (so we can check) but assuming it is not asked for, we only need to print if we want to test our function.


Got it! Well, it didn't ask for the print command, so i didn't use. Thanks for the answer!


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