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

I don't know. Why it not work.

anyone advice this code for me.I am not sure what wrong about my code.It doesn't work.I thing that should be work.

even.py
import random

start = 5

while start:
    num = random.randint(1, 99)
    def even_odd(num):
        # If % 2 is 0, the number is even.
        if num % 2 == 0:
            print("{} is even.".format(num))
        # Since 0 is falsey, we have to invert it with not.
        else:
            print("{} is odd.".format(num))
        return not num % 2
    start -= 1
    even_odd(num)

2 Answers

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

Hi there! I see you completed the first two steps without problem However, you are not following the instructions of the challenge in the third step. Here is a quote from the instructions:

Make a while loop that runs until start is falsey.

There is currently no while loop in your code. Here's another hint :bulb:. The even_odd function provided by Treehouse should not be altered at all. You're supposed to call the even_odd function from within the while loop and use the result to determine what to print. Give it another shot with these tips in mind :smiley:

Hope this helps! :sparkles:

Thank you.Jennifer Nordell