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.

Jirka Michalik
11,573 PointsAlright, last step but it's a big one.
Hello lads,can anybody help me? It seems that my code is right, but the challenge didn't accept that
import random
start = 5
while start > 0:
rand_number = random.randint(1,99)
start -= 1
if even_odd(rand_number) == True:
print("{} is even".format(rand_number))
else:
print("{} is odd".format(rand_number))
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
3 Answers

Reyam Marcos
Courses Plus Student 10,367 Pointstry this one,
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:
number = random.randint(1, 99)
if even_odd(number):
print("{} is even".format(number))
else:
print("{} is odd".format(number))
start -= 1
hope it helps

Thomas Fildes
16,201 PointsHi Jirka,
I used the following code to pass this challenge:
while start:
randomNumber = random.randint(1, 99)
if randomNumber % 2 == 0:
print("{} is even".format(randomNumber))
else:
print("{} is odd".format(randomNumber))
start -= 1
The start variable needs to decrement by 1 after the if statement and the if statement needs to check if the number is even by using modular (%). Hope this helps! Happy Coding!!!

Jirka Michalik
11,573 PointsOkay :) thank you guys