Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
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