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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Adam Tyler](https://secure.gravatar.com/avatar/a4118a8a52f8344fb48551f27ccee856?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Adam Tyler
14,865 Points'Wrong number of prints!'
My code produces an answer in work spaces correctly, i.e if num = 12 it will print '12 is even' or is num = 77 it will print '7 is odd', why is this the wrong number of prints?
import random
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
start = 5
while start == 5:
num = random.randint(1,99)
if even_odd(num):
print('{} is even'.format(num))
else:
print('{} is odd'.format(num))
start -= 1
1 Answer
![Jason Anders](https://uploads.teamtreehouse.com/production/profile-photos/3512822/micro_Jason_s-Pic.jpg)
Jason Anders
Treehouse Moderator 145,859 PointsHey Adam,
The challenge is not letting you pass, because it is expecting 5 different numbers to be checked. This is part of Task #2 when you assign start
the value of 5.
Then, in Task #3, it wants the while
loop to run as long as start
is "truthy", but your loop will only run once, because you are checking to see if start
equals 5, which it does but only for the first iteration of the loop. So, you are only checking one number instead of 5.
All your code is correct, except for the condition of the while
loop. You just need to change that first line so it is checking if the value of start
is "truthy" or "falsey" ... HINT: if you're checking for the "truthy" side of a boolean, you don't actually need a value there to check against. ... EXAMPLE: start == 5
checks if the value is five, but just start
alone will check for truthy
.
I hope this helps. Otherwise, good job. Just that one fix and it will pass.
Keep Coding!