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

yusuf patat
yusuf patat
572 Points

please help

help me!

even.py
def even_odd():
    number=int(input("write a even number "))
    if number %2==0:
        True 
    else:
        False

1 Answer

Oszkár Fehér
Oszkár Fehér
Treehouse Project Reviewer

Hi Yusuf. Your method it's almost finished, first of all you don't need the user "input" method, the number it should be provided in the method as an argument

def even_odd(number):

From here the if statement it's ok just it's missing the return keyword

if number % 2 == 0:
    return True
else:
    return False

or short version

if number % 2 == 0:
    return True
return False

in this case you don't need to specify the "else" to, the if already taking care to not pass False if the remainder it's 0 Also for best practice use the right spacing between elements

number % 2 == 0

not

number%2==0

This is still working but for better reading it's better with spacing and also in the future it will not cause headache. I hope it will help you to understand. Happy coding