Hi, this is the part of the code that should create a function that returns the absolute value of the entered integer or float. I can’t understand what’s wrong with him, here is 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 I checked the code by typing 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'
source share