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

Brian S.
Brian S.
3,176 Points

Hmmm... any suggestions? Code is doing as I expect, still not getting answer correct.

i also tried altering the Else to: else num % > 0 : print('False') break

even.py
def even_odd(num):
    while True:
        if num % 2 == 0:
            print('True')
            break
        else:
            print('False')
            break

2 Answers

Hey there!

1) Remove the loop and "break" statements-- You don't need to check if a number is odd or even more than once

2) Don't print true or false, use return instead :D -- This is how you get the value out of the function for reuse, rather than just showing the answer on the screen.

Your use of the modulo function is spot on though!

Brian S.
Brian S.
3,176 Points

wow, i was doing way too much. Thank you

Kristian Gausel
Kristian Gausel
14,661 Points

I dont understand why you use a loop. Also it says you should return true or false, not print it. The code looks something like

def even_odd(num):
    return num % 2 == 0
Brian S.
Brian S.
3,176 Points

I dont understand why i used a loop either, in hindsight. Thank you