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

what shoul i put in between the () it doesent say what to add

create_a_function.py
def is_odd(num):
    if 

2 Answers

Josh Keenan
Josh Keenan
20,315 Points

What you have between the () currently, num, is perfectly fine.

Now you have to figure out if a number is odd, to check if a number is divisible by 2 you need to use the % operator. It checks if there is a remainder, so if there is a remainder we know it is an odd number.

Hope this helps, feel free to ask for help if needed, good luck!

but how do i use the % im kind of connufuss

Josh Keenan
Josh Keenan
20,315 Points

If we wanted to know if a number was divisible by 3, it would look like this:

if num % 3 == 0:

This says, if the number is divisible by 3, then we can do whatever.

You want to check if it is NOT divisible by 2

ohhh i get it now thanks i migth have a idea now

Josh Keenan
Josh Keenan
20,315 Points

You got this, I believe in you!

by the way should i make a variable for num???

Josh Keenan
Josh Keenan
20,315 Points

num is already like a variable itself, you don't ever need to make a variable for a parameter, you can just use the parameter in the same way.

def id_odd(num): if num % 4 == 2: answer = True elif num % 5 == 1: answer = False return answer

result = int(input("fagagaaga"))

i try is but it doesent work

Josh Keenan
Josh Keenan
20,315 Points

You were close:

def is_odd(num):
    if num % 2 != 0:
        return True

ahhhh come on is wa a !=

thank you for you time you a great person thank you for you time

Josh Keenan
Josh Keenan
20,315 Points

!= is the not equal to operator