Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Task 1 is no longer passing

Hi I am stuck at Python Basics Even/Odd challenge task 3 of 3. I got tasks 1 and 2 correct, but when I pressed check work at task 3, I keep getting the Oops! It looks like Task 1 is no longer passing error. Would someone kindly help?

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

    start =-1

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing great, but you have two typos. One will cause a syntax error and the other causes an infinite loop. The most common reason to receive a "Task 1 is no longer passing" is because of syntax error. At this point, the code can no longer be interpreted/compiled.

Typo 1:

You typed:

nnumber = random.randint(1,99)

But you clearly meant to type:

number = random.randint(1,99)

Note the double "n" on the beginning of "nnumber". Later on, you then try to use the variable number which hasn't been defined.

Typo 2:

You are trying to decrement the value of start, but you got your minus sign and equals sign in the wrong order. This is syntactically valid, but doesn't do what was intended. Instead of decreasing the value of start by 1, you are setting the value of start to negative one (-1). The value of start will be truthy any time it is a non-zero number. This includes negative numbers. This results in the evaluation of while start always being truthy which leads to the infinite loop.

You typed:

start =-1

But you meant to type:

start -= 1

Note the reversal of the minus and equal signs.

I hope this helps! :sparkles:

Thank you so much, Jennifer! I also changed the "number" to num and it worked!