Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Letter Game App Even or Odd Loop

ravi thotapalli
ravi thotapalli
Courses Plus Student 1,113 Points


I tried this script in workspaces and it works fine. However when I put it in the answer page. I get try again. Not sure if I have a problem understanding the problem or no ? Could anyone pl let me know if I am making a mistake here.

import random def even_odd(num): start = 5 while start != 0: num = random.randint(1,99)

# If % 2 is 0, the number is even.
    if num % 2 == 0:
        print ("The number {} is even ".format(num))
        print ("The number {} is odd ".format(num))
    start = start - 1



you shouldn't need to test the number being odd or even- the method even_odd does that for you. You should just do: if even_odd(num): print(your message goes here) else: print(your else message here)

start -= 1

1 Answer

Try starting your while loop like this: while start: