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

Creating and using functions in Python

M stuck

2 Answers

def is_odd(value):
    if value % 2 == 0:
        print("False")
else:
    print("True")
return value

MOD: I updated the formatting of your code so people can follow it more easily. See the link to the Markdown Cheatsheet (below the text entry box) for how to do this.

Louise St. Germain
Louise St. Germain
19,424 Points

Hi! You'll need to indent the second half of your code so that the "else" lines up with the "if", and so that the return statement is still inside your function. Like this:

def is_odd(value):
    if value % 2 == 0:
        print("False")
    # Indent these next lines by one more tab each.
    else:
        print("True")
    return value

Also, I suspect that you need to return either True or False. Right now, it just returns your original number, which isn't that useful.

So, instead of printing "True" and "False", try returning True and False. Then you can remove the final "return value" line.

I hope this helps!

Thanks Louise st Germain