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

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!