Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Brian S.
3,176 PointsHmmm... 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
def even_odd(num):
while True:
if num % 2 == 0:
print('True')
break
else:
print('False')
break
2 Answers

zy93
Python Web Development Techdegree Student 6,879 PointsHey 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!

Kristian Gausel
14,649 PointsI 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.
3,176 PointsI dont understand why i used a loop either, in hindsight. Thank you
Brian S.
3,176 PointsBrian S.
3,176 Pointswow, i was doing way too much. Thank you