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 trialburgerk
882 Points"Task 1 is no longer passing"
Why?
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
def main()
while start:
ri = random(randint(1,99))
if even_odd(ri) == True:
print "{} is even".format(ri)
else:
print "{} is odd".format(ri)
start -= 1
return
main()
3 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou are doing things the challenge does not ask for. it just asks for a while loop, not a function, so the empty function body, missing colon, errant return statement and call to main() are throwing errors.
burgerk
882 PointsAppreciate the reply, James, thanks. I wrapped the code in a function to begin with because I was getting that error even w/o wrapping in a function and just thought I'd try. I get frustrated sometimes w/ these challenges because whenever I get that error "task 1 is not longer passing" - it's very obtuse and I can't figure out what's causing it, and I usually have to roll back and start all the challenge questions over. The challenge instructions are usually concise enough so that I don't run into this problem, but it's pretty maddening when it happens. Just venting...
thanks again - paul
james south
Front End Web Development Techdegree Graduate 33,271 Pointsit often says that when you introduce an error in the current task. it rarely if ever is actually because your code from a previous task is suddenly not acceptable any more. you don't have to start over.