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

samuel fiori
samuel fiori
4,497 Points

BUG in "Challenge Task 2 of 3" in the "Letter Guessing Game"

The first task was: "For this challenge, we're going to need to use the random library. Add an import to the top of your file to bring it in." What I did, but when I've tried the second Task: "Here's another easy step. Make a new variable, outside of the even_odd function, named start that's assigned to the number 5." It said that the first task no longer is passing.

That's a bug, right?

Thanks for 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 % 

start = 5

2 Answers

andren
andren
28,558 Points

If your code contains an error that crashes the challenge checker while it tries to verify that your code still passes the previous tasks then it will report that it does not pass the first task, even if the error in your code was not added in task one.

It's a misleading message, but technically accurate as the code does indeed not pass the first task anymore, since it actually just crashes outright.

The issue in your code is that you have accidentally removed the number 2 from the last line of the even_odd function. If you add it back like this:

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

Then your code will pass the second task.

samuel fiori
samuel fiori
4,497 Points

AH, of course! I just thought they set me this mistake, that I fix it on my own but I tried again and I really just removed the 2 accidentally. MY BAD ^^ Thank's for help though!