I must be having a bad day because this is the second one in a row I can't figure out.

Oops, try again. Your function fails on is_int(-2). It returns False when it should return True.

It's supposed to check to see if a number is an integer and include negatives and decimal zeros.

def is_int(x):
    if x == int:
        return True
        return False


x will not equal to int, but its type may.

if type(x) == int:

However, I don't believe we are expected to use the built-in to match the type. Can you think of another way?


That does help, but you're right. Using the type and int is not enough. I somehow need to include number that have a decimal followed by 0. Like 7.0. Not certain how to explain that in code form. I feel like they gave me a hint by saying "If the difference between a number and that same number rounded down is greater than zero, what does that say about that particular number?". Again, I don't know how I'm supposed to represent this in code.


Using the round() function,

return round(n) == n

Using a modulo operation,

return not n % 1

Both of these should let a float such as 7.0 pass.


Thanks! That's exactly what I needed. It worked perfectly.