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 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.

def even_odd(number):
    if number % 2 == 0:
        return ("True")
        return ("False")

1 Answer

Alex Koumparos
Alex Koumparos
Python Development Techdegree Student 36,886 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.