2.is_even


#1
def is_even(x):
    if x%2== int:
        return True
    else:
        return False

is_even(36) returned false instead of true.

Just wondering, int means integer right?


#2

yea, is int means integer. But you don't want to check if it is a integer, you want to check if the number is even. The modulo operator is a good way to achieve this. But then you should check if the remainder is 0


#3

Thank you, it works, I forgot you could do that. I was thinking if the answer of a number/2 is an integer then the number would be even. I didn't realise modulo gives the remainder of a division not the answer. Never mind :slightly_smiling: