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

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: