Is_even, please help


I'm stuck on is_even, can someone plz tell me how to find if the number is even?


Hello @tunihi,

def is_even(num):
# Return True or False, depending on if the input number is odd.
# Even numbers are 0, 2, 4, 6, and so on.

The other version would be is_odd

def is_odd(num):
# Return True or False, depending on if the input number is odd.
# Odd numbers are 1, 3, 5, 7, and so on.

Hope this will help you :slight_smile:


hi @tunihi,

as @0xb4dc0ded mentioned, a number that is even includes examples like 2, 4, 6, 8 and so on. What is a common similarity among all these numbers? That's right, they are all divisible by 2. So all that you need to do is to find out how you can check if a number if divisible by 2.

Here's a final hint: recall the modulo function, %.


I know the odd and even numbers, because I read the question a lot but I'm not sure how to check it. The internet says to do num % 2 == 0 but it raises an error saying invalid syntax
x % 2 == 0


I know that, it still doesn't work


mind sharing your full code?


I don't understand the issue.

If you want to check if a number is even, e.g. 5, just write is_even(5) and assign it to a variable or a if-statement.


def is_even(x):
    if x % 2 == 0
        return True
        return False


nvm, missed a colon.


I don't understand the purpose of this code, buuuut I didn't code much in Python at all.
So if it works, than it's good .... I guess :smiley:


good job noticing it :slight_smile: