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

Tobias Erhart
Tobias Erhart
2,481 Points

"Oops! It looks like Task 1 is no longer passing." Why comes that message when I try to submit my Code challenge?

Every time when I try to submit the last code challenge in Python Basics this message comes and i really have no idea why

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:
    num = random.randint(1, 99)

    if even_odd(num) = True:
        print("{} is even".format(num))
    else:
        print("{} is odd".format(num))

    start = start - 1

1 Answer

andren
andren
28,558 Points

Whenever you try to pass a task the code checker will usually run your code though the criteria of each task verifying that you have not removed any of the code from the previous tasks. However if you have any code that causes the code checker to crash (like invalid syntax) then it will mark the first task as not passing. Even though the code with the fault was not necessarily added in the first task.

The fault in this case is a typo in this line:

if even_odd(num) = True:

You have used a = instead of ==, meaning you are telling Python to set a functional call equal to true, which is obviously not valid code. Correct that typo and your code will pass.

Tobias Erhart
Tobias Erhart
2,481 Points

Thank you! What a stupid mistake i made there haha