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

Balazs Bodor
Balazs Bodor
905 Points

Im having difficulties seeing my syntax error

So, as I gather from this challenge, everything should be inside my While loop. But I'm having difficulties understanding where I'm going wrong. Should I start the while loop with random.randint(1, 99)? Am I formating the "print" statement wrong?

Also, I "decremented start by 1". I guess they mean that one should just adjust 5 to 4 in the "Start" statement, but what does that do?

Im stuck.

Thanks in advance

even.py
import random
start = 4

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

The reason for error is due to indentation at "break statement" and also you failed to call the function

1 Answer

import random start = 5

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