Why Does This Print Statement Not Execute?


why does the print statement not execute when used within a function

 def distance_from_zero(d):
  if (type(d)==int or type(d)==float):
    return abs(d)
    print something
    return "Nope"

“something” used in the print statement doesnt print

FAQ: Learn Python: Functions - Review: Built-In Functions

By default, a function returns None at the end of the function. If we want to return something else at the end of the function, we can use the return keyword.

Given return is the last thing a function does, when a return keyword is reached, the function ends

so it never reached the print statement. Beside, something is a undefined variable at the moment, shouldn’t it be a string?

Also, why place the function call inside the function body?