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.

Python Practice Creating and Using Functions in Python Practice Functions That's Odd

Christopher Buckhout
Christopher Buckhout
Python Development Techdegree Student 786 Points

is_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

If 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

2 Answers

Steven Parker
Steven Parker
210,425 Points

Being "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