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 trialAayush Mitra
24,904 PointsI don't know what it means by Wrong number of prints.
I do not understand why it keeps on saying Wrong number of prints. Can someone please help me? Thank you!
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 == True:
start -= 1
a = random.randint(1,99)
if even_odd(a):
print("{} is even").format(str(a))
else:
print("{} is odd").format(str(a))
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsWhile start
is "truthy" it is not be equivalent to True
, therefore the while
will never exit regardless of the value of start
. Instead, simply refer to the "value" of start
. When start
is 0, then it will be interpreted as "false" (but still not equivalent to False
"):
while start:
Also, the format()
method is part of the string. It should immediately follow the string. Remove the closing paren between the string and the .format
method.
Post back if you have more questions. Good Luck!!
Aayush Mitra
24,904 PointsAayush Mitra
24,904 PointsThank you so much.