# 3/15 i made this. is that enough?

#1
``````def is_int(x):
if x % 1 == 0:
return True
else:
return False``````

i just thought how to pass this, obviously other threads on the forum make it twice as complicated. Is that enough? It works for every number from - 999999999999,0 to 99999999999999.0. It doesn't really test if its an integrer, but it works

#2

you can try this

``````def is_int(x):
return x % 1 == 0 if type(x) in [float,int] else None

print is_int(34)
print is_int(34.9)
print is_int("34")``````

#3

Hi,
I think it's fine you can do this.
I wrote my function like this

def is_int(x):
y = int(x)
if (x-y) == 0:
return True
else:
return False

Regards

Practice Makes Perfect 3/15: is int. Is this code valid or cheating?
#4

I understand it, but how do I actually make it print True or False? I tried modifying it, but when i tried some other code for this exercise, even when it contains True or False it still doesn't print it out in the console.

#5

It should be as simple as typing:

``````print is_int(500)
#should return true``````

#6

oh yeah, i'm ■■■■■■■■, i forgot to pass it in the function... i just wrote print 5 or something, lol. thanks.

#7

Happens to the best of us. Haha

#8
``````def is_int(x):
if x == int(x):
return True
else:
return False``````