3/15 my code


#1
def is_int(x):
    a = str(float(x))
    p1 = int(a.split(".")[0])
    if p1 - x == 0:
        return True
    else:
        return False

#2

@th936

Your code is prone to errors. If you are going to use the built in type check you might as well do this.

def is_int(data):
    try:
        return int(data)
    except TypeError:
        print("You failed to enter valid information")

You can of course change what some of this does but it should get my point across.

If you put in a string into your function it will flip it's wig.


#3

Thanks @zeziba, that's a good suggest.


#4

def is_int(x):
return x%1==0

I think it's the simplest solution.