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.

Python Python Basics (2015) Number Game App Even or Odd

Robert Femi
Robert Femi
689 Points

This one should be short and sweet. Challenge Task 1 of 1

Why isn't the code accepted if I put ("True") and ("False") but it's accepted if remove brackets and quotation marks? Spent a LONG time figuring that out and would like to learn why so at least it won't be a complete waste of time. Would appreciate if someone can explain that to me. Many thanks.

even.py
def even_odd(number):
    if number % 2 == 0:
        return ("True")
    else:
        return ("False")

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,862 Points

Hi Robert,

Strictly, the problem is just with the quotation marks, not with the parens.

return (True)

will pass but

return ("True")

will not. This is because True and "True" are completely different data types. True is a boolean (a data type that can only ever be True or False, and Python can understand semantically what true and false mean) and "True" is a string (and Python doesn't generally have any way to understand what is semantically in a string, just that it is a sequence of characters).

As for the parentheses, they are completely redundant and should be removed.

Cheers

Alex