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!

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

Selemawit Gebremedhin
Selemawit Gebremedhin
1,331 Points

create a function that determines if a specific value is odd.

I tried this both methods but still it is giving me error and I don't know. Help!!!

num = int (input ("Enter number: ")) def is_odd (num): if num % 2 != 0: return True else: return False

or num = int (input ("Enter number: ")) def is_odd (num): if num % 2 == 0: return False else: return True

1 Answer

You could try this:

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


while True:
    num = int(input("Enter a number:   "))
    print(is_odd(num))