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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Valeria Martucci](https://secure.gravatar.com/avatar/3a94973d2f0587b7355551ada4db5305?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Valeria Martucci
1,265 PointsPlease help me with the answer. I ve tried if number %2 == 0 and is not right...
Even numbers have not a remainder... but is seems impossible to translate this in python...
def even_odd(number):
if number %2 = 0
return True
else:
return False
2 Answers
![Alex Koumparos](https://uploads.teamtreehouse.com/production/profile-photos/8418842/micro_IMG_1256__cropped_and_reduced_res_.jpg)
Alex Koumparos
Python Development Techdegree Student 36,887 PointsHi Valeria,
Remember that in Python ==
is the test for equality and =
is used to assign a value to a variable.
If you wanted to make the function even shorter, you can use the fact that number %2 == 0
is itself a value, either True
or False
and just return that. Consider the following example:
return a == b
If a
is the same as b
then a == b
is True
so this line of code would return True. If a
isn't the same value as b
then a == b
is False
and this code would return False.
Cheers
Alex
![Valeria Martucci](https://secure.gravatar.com/avatar/3a94973d2f0587b7355551ada4db5305?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Valeria Martucci
1,265 PointsYou are right... ant that's my mistake...Is the synthax correct? I ve tried again using the right == but it's still not working
![Alex Koumparos](https://uploads.teamtreehouse.com/production/profile-photos/8418842/micro_IMG_1256__cropped_and_reduced_res_.jpg)
Alex Koumparos
Python Development Techdegree Student 36,887 PointsHi Valeria, you are also missing the colon at the end of your if
statement. Remember that any time you have a statement that will cause the next line to be indented, you use the colon at the end of the line:
if <some test>:
<do something>
else:
<do something else>