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

Paul Je
Paul Je
4,435 Points

Which part would I fix?

Not sure which part I should work on.. Seems close to being right to me.. thanks in advance!!

even.py
def even_odd(number):

    number = int(input("Number?: "))

    if number % 2 == 0:
        return True

    if number % 2 != 0:
        return False

2 Answers

Henrik Christensen
seal-mask
.a{fill-rule:evenodd;}techdegree
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

You need to remove the number variable to complete the challenge:

def even_odd(number):
    if number % 2 == 0:
        return True
    elif number % 2 != 0:
        return False

Happy coding! :-D

Cheo R
Cheo R
37,150 Points

Hello Paul, you're on the right track. The directions don't state you need user input, so you can omit

number = int(input("Number?: "))

And since you're only testing if a number is either even or odd, you could just test for it either being True or False. If it is True, the return statement would return control back to the caller (i.e it won't execute the code after that). So you can cut your code down to using only one if comparison.

def even_odd(number):

    if number % 2 == 0:
        return True

    return False