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 trialWeuler Borges
2,095 PointsTask 1 is not passing
Is this challenge correct? Everytime I complete Task 3 (with a seemly correct code) it says "Oops! It looks like Task 1 is no longer passing" and Task 1 is all about importing random...
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 not start == 0:
num = random.randint(1,99)
if not even_odd(num):
print("{} is even".format(num))
else
print("{} is odd".format(num))
start = start - 1
1 Answer
Steve Hunter
57,712 PointsHi there,
You've not got a colon on your else:
clause - and you don't want to negate the test of even_odd
in your if
statement, as the method already negates its output.
Steve.
Weuler Borges
2,095 PointsWeuler Borges
2,095 PointsHi!
Thank you so much for helping me spot that one. There might be an issue with the correction system for this one though, because it were kind of pointing me back to a task with no errors instead of saying that my answer on task 3 were wrong!
Regards!
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsUnfortunately, the challenges do that sometimes. Generally, if you've not changed your task 1 code, you can be sure that it still works and that the last thing you did is where the error lies. I don't get that error when I run your code - it might be browser-specific, perhaps?!