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

Mario Sanchez Carrion
Mario Sanchez Carrion
17,541 Points

Task 1 is no longer passing...

Everything seems to be OK but program keeps telling me "It looks like Task 1 is no longer passing". Stumped... Need some help. Thanks!

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

1 Answer

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

Hi there! First, you're doing great! When you receive a "Task 1 is no longer passing" it is most often because you've introduced a syntax error into your code. Such is the case here.

The parentheses in your print statements are a little off. the .format should come immediately after the string. Take a look:

# you typed this
print("{} is odd").format(game_num)

#But it should be...
print("{} is odd".format(game_num))

The misplacement of the parentheses is causing a compiling error which means that the code can no longer be interpreted. But besides this, keep in mind that even_odd will return True if the number is even and False if it is odd. So once you fix the parentheses you will need to adjust which statement is printing when. :smiley:

Hope this helps! :sparkles:

Mario Sanchez Carrion
Mario Sanchez Carrion
17,541 Points

Thanks Jennifer! I need to be more careful with my syntax.