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) Number Game App Even or Odd

oz izhak
oz izhak
1,940 Points

can someone help me with the Challenge Even/odd..? i dont no how to start...:(

...

even.py

4 Answers

oz izhak
oz izhak
1,940 Points

Tnx Stuart !! understood.

Stuart Wright
Stuart Wright
41,118 Points

The first line of your solution should be:

def even_odd(num):
    # your code goes here

What this does is define a function called even_odd, with one argument, num. From here, you need to write an if statement to return True if num is even, or False if num is odd. Good luck!

oz izhak
oz izhak
1,940 Points

def even_odd(test) if test % 2 == 0: return True else: return False

i thing i got it.

but i dont know what the sing % using for ..

Stuart Wright
Stuart Wright
41,118 Points

That looks like the correct solution.

The % symbol gives the remainder after dividing an integer by another integer.

So 11 % 4 = 3. Because 11 divided by 4 is 2, with 3 left over.

It works for your even_odd function because any even number % 2 will be 0, and any odd number % 2 will be 1.