Hi this is a piece of code that is supposed to create a function that returns the absolute value of the inputted integer or float. Can't seem to figure out what's wrong with it, here's the code and the error. Any help is appreciated!
here is the code for the function:
import math
def distance_from_zero(num):
type_entry = type(num)
if type_entry == int:
return math.abs(num)
elif type_entry == float:
return math.abs(num)
else:
return "Not an integer or float!"
here is where I tested out the code by printing the result
print distance_from_zero(4)
here is the error that occurs
Traceback (most recent call last):
File "python", line 12, in <module>
File "python", line 5, in distance_from_zero
AttributeError: 'module' object has no attribute 'abs'