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.

Roderick Sang
6,891 PointsTask One Stops Passing
Whenever I hit Part 3 of this question, it tells me Task 1 no longer passes. And when I try to run my code in Task 1 without changing it back, it tells me there's a syntax error that I don't see.
Can anyone tell me where I'm going wrong?
import random
start = 5
while start:
random_num = random.randint(1, 99)
if even_odd(random_num) > 0:
print("{} is even".format(random_num)
else:
print("{} is odd".format(random_num)
start--
def even_odd(num):
# If % 2 is 0, the number is even.
# Since 0 is falsey, we have to invert it with not.
return not num % 2
1 Answer

David Axelrod
36,073 PointsHey Roderick!
even odd spits out a boolean. try just checking that on its own. Just passed with the code below. it gave me the same, 'task one is not passing' but it was just because i was originally using the '{}' % var instead of normal format
import random
start = 5
def even_odd(num):
# If % 2 is 0, the number is even.
# Since 0 is falsey, we have to invert it with not.
return not num % 2
while start:
randnum = random.randint(1,99)
if even_odd(randnum):
print("{} is even".format(randnum))
else:
print("{} is odd".format(randnum))
start -= 1
Roderick Sang
6,891 PointsRoderick Sang
6,891 PointsThanks, David!
Admittedly I tried changing my code myself to look like yours (( that if even_odd(randnum) line ))and it didn't work, but copying and pasting your code DID work, so... I guess it's just something I wasn't seeing, hah.