Hi, I’m very stuck on the exercise “is_int”, could some one help me please?
For the purpose of this lesson, we’ll also say that a number with a decimal part that is all 0s is also an integer, such as 7.0.
Define a function is_int that takes a number x as an input.
Have it return True if the number is an integer (as defined above) and False otherwise.
is_int(7.0) # True
is_int(7.5) # False
is_int(-1) # True
Your function fails on is_int(-2). It returns False when it should return True.
def is_int(x): if x == int or x > 0: return True else: return False