Is_int BUG


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/3?curriculum_id=4f89dab3d788890003000096


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
    else:
        return False

The above code should pass the test


#2

The exercise isn't to check the type


#3

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


#4

I get the point now, fixed code and passed

thanks


#5

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