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

brandonlind2
brandonlind2
7,823 Points

Does anyone know why this even_odd function isn't working?

I'm doing a challenge and it's telling me it's not returning the correct answer

even.py
def even_odd(num):
    result= num%2

    if result == 0:
        return "even"
    else: 
        return "odd"

2 Answers

Jonathan Malin
Jonathan Malin
9,546 Points

It looks like to me you are returning "even" or "odd" when you need to be returning True if it is even and False if it is odd.

Kerry Collier
seal-mask
.a{fill-rule:evenodd;}techdegree
Kerry Collier
Front End Web Development Techdegree Student 16,151 Points

You should be returning True and returning False. Try that, it should work then. You could simplify it a bit and just do the comparison in the if part, but either way should work.