Welcome to the Treehouse Community
Looking to learn something new?
Question about an exercise that asks me to create an odd_even function
The question asks me to create a function called odd_even that takes one parameter that is a number, and check if that number is even or odd. If even return True, if odd, return False. I created the following function which works fine in Visual Studios Python IDE. But I got "Bummer" when I checked my work Perhaps Treehouse wanted me to use the keyword return instead of print. But they didn't specify that as a requirement as far as I can tell.
def even_odd(num): if(num%2 ==0): print("True") else: print("False")
There are a couple things preventing you from getting it right:
One is you shouldn't be using parenthesis in your if statements in Python. Number two: Your logic looks good, however the assignment tells you to "return" the result, not print the result. You were real close though :)
In case you still don't understand here is my code:
def even_odd(num): if num % 2 == 0: return True else: return False