Help Needed Is_int


Exercise Practice Makes Perfect #3

My code errors saying that my function is_int(-2) fails. Returns False when it should return True.

I thought my first if statement took care of this since -2 is an integer

def is_int(x):
    if x == int:
        return True
    elif x == float:
        return True
    elif abs(x) == str(x) + "." + "0":
        return True
        return False



    elif x == float:
        return True

are you sure you want to return True for all floats? I don't think so

no, int doesn't see negative values (and zero) as integers. integers are positive numbers. You need more help, or do you think you can go further now i pointed to your mistake?


I believe I will be able to figure it out from here. Thanks for your assistance.


okay, good luck! the help line stays open if you can't figure it out :wink:


Look up python floor division. That should clear things up. Hope it helps!


>>> x = 3.14
>>> x == float
>>> type(x) == float

However, we are told not to refer to a built-in method. The suggestion above is more on target, as is the modulo example given in the Hint.