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 trialJonathan Camacho
1,504 PointsI cannot grasp what is wrong, please help.
I tried to condition that if it was a whole number, without remainders, then it would be even. So I came up with this. However, it says that it did not have the correct answer.
def even_odd(number):
if number is int:
return True
else:
return False
3 Answers
Emmanuel Jimenez
21,666 PointsHi Jonathan!
You need to use the module operator (%). When you divide a number by 2 and the residue is 0, it means that number is even. If is not 0 so the number is odd. Here the module operator y very helpful.
Try this:
def even_odd(number):
if number % 2 == 0:
return True
else:
return False
Per Karlsson
12,683 PointsHi @jonathancamacho2,
Try this instead
...
if type(number) is int:
...
Cheers, Per
Jonathan Camacho
1,504 PointsIt did not work. View the challenge please
Per Karlsson
12,683 PointsHi Jonathan,
I thought this was a general question with type comparison. My bad. See Emmanuel's answer below.
Good luck!
peter Bowden
369 PointsBuddy you just need to read the principals the course gives you to follow and fix or correct them you will be fine comments like the one you made are invalid ('Like the way I did that ;)') you will be fine think for a little before making a question as know it all's myself jump onto the subject like animals haha happy coding broski ;)
peter Bowden
369 Pointspeter Bowden
369 PointsClick this link https://teamtreehouse.com/perkrlsn or read the below comment as he explains how to solve the problem buddy keep it 100!