Is_int BUG


error message: Your function fails on is_int(7.0). It returns False when it should return True.

7.0 is float not an int
7 is an int
if you execute print type(7.0) you will get float, ergo the exercise has a bug.

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

The above code should pass the test


The exercise isn't to check the type


if that was the challenge, it wouldn't be a challenge

to succeed this exercise, when a float has a 0 as decimal, it should be considered as integer


I get the point now, fixed code and passed



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.