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

Odd Even loop

Challenge Task 3 of 3

Alright, last step but it's a big one. Make a while loop that runs until start is falsey. Inside the loop, use random.randint(1, 99) to get a random number between 1 and 99. If that random number is even (use even_odd to find out), print "{} is even", putting the random number in the hole. Otherwise, print "{} is odd", again using the random number. Finally, decrement start by 1.

I'm getting Wrong number of prints error. What am I doing wrong?

import random

start = 5
while start is True:
    def even_odd(num):
        num = random.randint(1,99)

        if num % 2 == 0:
            print("{} is even".format(num))
            print("{} is odd".format(num))
        start - 1

3 Answers

bowei zhou
bowei zhou
1,762 Points

while start>0 and start<6:

Thank you but that can't be the answer since at the end of the instructions it says "Finally, decrement start by 1." 4 is still greater than 0 and still less than 6. I don't see how your code helps. I could be wrong, but I don't see it.

bowei zhou
bowei zhou
1,762 Points

oh yes, what about start -1 TO start-=1

But!! It is a loop so I stand corrected! So it could just decrease by one until it was lower than 0.