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

Hope Mallary
Hope Mallary
900 Points

it says I have the wrong number of prints??

This file keeps telling me that I have the wrong number of prints but I don't understand what is wrong.

even.py
import random

start = 5

def even_odd() :

    while start == True :

        number = random.randint( 1, 99 )

        if number % 2 == 0 :

            print("{} is even").format(number)

        else :

            print("{} is odd").format(number)

        start = start - 1

    # If % 2 is 0, the number is even.
    # Since 0 is falsey, we have to invert it with not.
    return not number % 2

1 Answer

Ryan S
Ryan S
27,276 Points

Hi Hope,

It looks like your logic is definitely on the right track. But in this challenge you need to create the while loop outside of even_odd. The even_odd function is already complete and you won't be adding anything to it or changing it in any way. So your code will be written after it.

However, you will need to call it in your while loop. even_odd() returns true if a number is even, and false if it is odd. So you can use it in place of your current if statement.

Good luck.