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 trialMario Sanchez Carrion
17,541 PointsTask 1 is no longer passing...
Everything seems to be OK but program keeps telling me "It looks like Task 1 is no longer passing". Stumped... Need some help. Thanks!
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:
game_num = random.randint(1, 99)
if even_odd(game_num):
print("{} is odd").format(game_num)
else:
print("{} is even").format(game_num)
start -= 1
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! First, you're doing great! When you receive a "Task 1 is no longer passing" it is most often because you've introduced a syntax error into your code. Such is the case here.
The parentheses in your print
statements are a little off. the .format
should come immediately after the string. Take a look:
# you typed this
print("{} is odd").format(game_num)
#But it should be...
print("{} is odd".format(game_num))
The misplacement of the parentheses is causing a compiling error which means that the code can no longer be interpreted. But besides this, keep in mind that even_odd
will return True if the number is even and False if it is odd. So once you fix the parentheses you will need to adjust which statement is printing when.
Hope this helps!
Mario Sanchez Carrion
17,541 PointsMario Sanchez Carrion
17,541 PointsThanks Jennifer! I need to be more careful with my syntax.