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

Ricardo Arenas
Ricardo Arenas
3,629 Points

Oops! It looks like Task 1 is no longer passing!!? HELP, I'M STUCK

This keeps popping up and I've rechecked Task 1 multiple times and it always accepts my answer until I get to Task 3 in which it magically stops working.

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 > 0:
    random_number = random.randint(1, 99)
    if even_odd(random_number):
        print("{} is even".format(random_number))
    else:
        print("{} is odd".format(secret_number))        
    start--
Ricardo Arenas
Ricardo Arenas
3,629 Points

*Fixed the secret_number mistake in the end for the appropriate random_number variable and it didn't make any difference.

1 Answer

Antonio De Rose
Antonio De Rose
20,884 Points
#almost there, do you want to have another go at it

# error 1 - can you minus like that is a question, better you use
# start-=1;

#error 2 - from where is the secret number coming.

#error 3 
#while start > 0 (this condition is wrong)
# HINT - true is 1 false is 0

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