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 trialChristopher Buckhout
Python Development Techdegree Student 786 Pointsis_odd Code Challenge
Hi Team, I'm struggling with the following code challenge: I'm unsure if I'm inputting the correct parameter and am unsure what's missing to get a return value true if the value isn't divisible by 2. Thanks in advance for the input!
def is_odd(value):
return value != 0
2 Answers
Steven Parker
231,236 PointsBeing "odd" isn't the same thing as "not equal to 0". But it would be odd if the remainder with 2 wasn't 0:
return value % 2 != 0
Christopher Buckhout
Python Development Techdegree Student 786 PointsThanks, @Simphiwe Masukume and Steven Parker for the input. This helps to break it down :)
Simphiwe Masukume
7,030 PointsSimphiwe Masukume
7,030 PointsIf a number is divisible by 2 then the remainder will be 0. if it isn't, however, we will get a remainder. To check what the remainder of a value is we use the % operator.
For example, 5 % 2 will return 1
~use an if statement to check if the remainder is not equal zero
~return True if it isn't