1.3 it's passing, but is it right?


#1

def is_int(x):
if x == round(x):
return True
else:
return False

print is_int(7.5)

The logic I went with is to check if the the number that is input to the function is equal to that number rounded thus checking if it is an integer. Is this a valid way to do it or did codecademy pass me on accident


#2
def is_int(x):
    if x == round(x):
        return True
    else:
        return False

print is_int(7.5)#False
print is_int(1.0)#True
print is_int(0.1)#False
print is_int(0)#True

Interesting approach. I didn't know about round() method before so I gave it a try. Looks all right, working for all float numbers.

P.S: If you add 4 blank spaces before your code, the indentation won't disappear. ^^