Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Please 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
Alex KoumparosPython Development Techdegree Student 36,862 Points
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
False and just return that. Consider the following example:
return a == b
a is the same as
a == b is
True so this line of code would return True. If
a isn't the same value as
a == b is
False and this code would return False.
You are right... ant that's my mistake...Is the synthax correct? I ve tried again using the right == but it's still not working