3/15 is_int modulo


#1

I am a little stuck on the is_int code. It fails on -2 saying the code below returns None when it should return True.

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

I have run print(-2 % 1) through python on my machine and it is coming out as 0!

Any information would be much appreciated.


#2

Hi,

you just forgot to include the return statement.


#3

:blush: oops, that makes all the difference. Thanks for your help.