Python Python Basics (2015) Number Game App Even or Odd

Please help me with the answer. I ve tried if number %2 == 0 and is not right...

Even numbers have not a remainder... but is seems impossible to translate this in python...

even.py
def even_odd(number):
    if number %2 = 0
        return True
    else:
        return False

2 Answers

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,857 Points

Hi Valeria,

Remember that in Python == is the test for equality and = is used to assign a value to a variable.

If you wanted to make the function even shorter, you can use the fact that number %2 == 0 is itself a value, either True or False and just return that. Consider the following example:

return a == b

If a is the same as b then a == b is True so this line of code would return True. If a isn't the same value as b then a == b is False and this code would return False.

Cheers

Alex

You are right... ant that's my mistake...Is the synthax correct? I ve tried again using the right == but it's still not working

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,857 Points

Hi Valeria, you are also missing the colon at the end of your if statement. Remember that any time you have a statement that will cause the next line to be indented, you use the colon at the end of the line:

if <some test>:
    <do something>
else:
    <do something else>