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 trialAshley Keeling
11,476 PointsI don't know why this isn't working
it says task 1 is no longer passing
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 is True:
random_number=random.randint(1, 99)
even_odd(num,random_number)
if random_number=False:
print("{} is even".format(random_number)
else:
print("{} is odd".format(random_number)
start-1
1 Answer
Manish Giri
16,266 PointsYou're close.
In the last line, your code is start-1
. This subtracts 1
from start
, but it doesn't modify start
itself. What you want is to decrement start
by 1
each time in the loop, so that when start
reduces to 0
, the loop is no longer true, and you exit.
So, start -= 1
.
Ashley Keeling
11,476 PointsAshley Keeling
11,476 Pointsthanks for the help I have now completed the challenge