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 trial

Python Python Basics (2015) Letter Game App Even or Odd Loop

Jose Palacios
Jose Palacios
1,332 Points

Oops! It looks like Task 1 is no longer passing.

I did the three activities but now and not able to submit the third one , I get the error : Oops! It looks like Task 1 is no longer passing. I go to the first task send it again but still same error Whats going on ?

even.py
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:
    rnum = random.randint(1,99)
    if even_odd(rnum) == True:
        print("{} is even".format(rnum))
    else:
        print("{} is odd".format(rnum))
     start -= 1

3 Answers

Hi Jose

Apart from an indentation error on the line that you decrease start by 1, your code seems to work just fine in the challenge.

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:
    rnum = random.randint(1,99)
    # also you change the first line of the if statement like so 
    #if even_odd(rnum):  its the same as ==True
    if even_odd(rnum) == True:
        print("{} is even".format(rnum))
    else:
        print("{} is odd".format(rnum))
     start -= 1 # check indentation here. You need to tab in 1 space
Jose Palacios
Jose Palacios
1,332 Points

Hello Andreas , I reallly appreciate you took the time to answer me . I fixed what you told me but if you see the subject of my question it talks about task 1 , the challenge has 3 task I did the three of them and first and second were ok but I get an error in task 3 refering to task 1 , do you understand what I mean ?

Hi Jose

Apologies for not understanding the question properly. I ran your code many times, the only way i could repeat the error, Task 1 no longer passing, is when i leave the indentation as it is in your original code. I am not sure how the challenge works out what error to throw, I agree it should have said, maybe something like, indentation error rather than showing task one no longer passing. When i have encountered this sort of problem, i tend to run my code locally or in workspaces to see what kind of errors i get, once i fixed all the errors, I start the challenge again step by step till it passes.The challenge doesn't always give you the exact error if that makes sense.

Jose Palacios
Jose Palacios
1,332 Points

Hello Kenneth , I did correct the indentation , but error remains [alt text](C:\Users\I304630\Desktop "foto1.png")

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

I just passed the challenge with your code (with the indentation corrected).

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Our challenges run through each task that you've completed, and the current one, each time you submit your code. So if something you write on task 3 causes a syntax error or some other unrecoverable error, the grader will say that task 1 is no longer passing. Unfortunately, there's no way around this because the failure happens before we get to any state where I could bubble up an error message to you.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

And, like Andreas cormack said, the indentation is wrong on your start -= 1 line. Likely this is causing an IndentationError which is causing the program to fail right away.

Jose Palacios
Jose Palacios
1,332 Points

Hello Kenneth , I did correct the indentation , but error remains.