Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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