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

Agustin Fitipaldi
Agustin Fitipaldi
1,644 Points

Task 1 no longer passing... I've been stuck on this for too long

i dont understand what it means by task 1 is no longer passing.

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:
    num = random.randint(1, 99)
    if even_odd(num) == False:
        print('{} is odd').format(num)
    elif even_odd(num) == True:
        print('{} is even').format(num)

    start -= 1

1 Answer

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

Hi there! You are soooo close on this one! The problem here is the placement of some parentheses. I'll show you in a minute. When you receive a "Task 1 is no longer passing" message, the most common reason for this is that you've introduced a syntax error in your code. When this happens your code can no longer be compiled/interpreted so even the correct code you've done before is not able to be checked. Let's take a look at the parentheses:

You typed this:

print('{} is odd').format(num)

But you meant to type:

print('{} is odd'.format(num))

The .format should come immediately after the string, the variable should go in parentheses and then the whole thing should go inside the print statement parentheses. Here's another example:

name = "Agustin"
print("Hello there!")
print("It's nice to meet you, {}".format(name))

Hope this helps! :sparkles:

Agustin Fitipaldi
Agustin Fitipaldi
1,644 Points

thanks a lot! couldn't have caught that on my own...