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

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

Christopher Buckhout
seal-mask
.a{fill-rule:evenodd;}techdegree
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!

create_a_function.py
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
231,248 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