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
I don't understand why it's saying is_odd(2) returns True, why my code doesn't work?
def is_odd(x): if int!=x/2: return True
Megan AmendolaTreehouse Teacher
Hi jack twist !
If you haven't already, I would suggest opening up a python workspace and playing around with your function. For instance, I ran this:
def is_odd(x): if int!=x/2: return True print(is_odd(2)) print(is_odd(1)) print(int) # Console >>> True >>> True >>> <class 'int'>
Right now your function is checking if
<class 'int'> does not equal the number passed in
x divided by 2. This will always be true because they will never be equal