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

Hoessein Abd
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Hoessein Abd
Python Web Development Techdegree Graduate 19,107 Points

What is this function doing and do i have to use it in the while loop?

def even_odd(num):
    return not num % 2

while start:
    random = random.randint(1, 99)
    if random % 2 == 0:
        print("{} is even").format(random)
    else:
        print("{} is odd").format(random)
    start -= 1

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

You do not have to use the provided helper function. It's included for your convenience.

Two errors observed in your code:

  • the format method needs to be applied directly to the string. Currently it's outside the print statement
  • you are over writing the random module by assigning the result of randint bank to random

Post back if you need more help. Good luck!!!