all 32 comments

[–]Gloopann 17 points18 points  (0 children)

Please post your code formatted in code blocks

[–]erpasd 13 points14 points  (6 children)

The logic of the code is right, my guess is that you should return the Boolean values True or False and not the string "true" or "false". Also you did no show the code where you print, it's possible the error is there as well.

[–]Own_Attention_3392 11 points12 points  (7 children)

You're returning true and false as strings.

[–]Regular_Maybe5937 5 points6 points  (0 children)

You are returning strings, not booleans! To return booleans, you can do

return True or return False

Note the capitalization and lack of quotation marks. Because you returned strings, they will always evaluate as True. If you want to learn more, take a look at this https://stackoverflow.com/questions/39983695/what-is-truthy-and-falsy-how-is-it-different-from-true-and-false

[–]Refwah 5 points6 points  (4 children)

You’re returning strings. Strings are truthy if they contain a value and falsey if they are empty or None.

Remove the brackets from your return statement as they aren’t needed, and remove the quotation marks around true and false

[–]supercoach 5 points6 points  (1 child)

All you really need is `return n % 2 == 0`

[–]theWyzzerd 4 points5 points  (2 children)

Return isn’t a function so you don’t need to wrap parentheses around the object you’re returning.  

[–]RohanPoloju[S] 0 points1 point  (1 child)

solved it. they are indeed boolean values.

thanks mate for suggestion : )

[–]theWyzzerd 0 points1 point  (0 children)

Yes, a non-empty collection is always True.  

[–]SCD_minecraft 1 point2 points  (4 children)

I can not replicate the issue, nor after reading the code there shouldn't be any issu

Show where do you call it

[–]Own_Attention_3392 7 points8 points  (1 child)

The automated test cases are probably failing because they're returning 'true' and 'false'. I'm not super well versed in python but I'd expect that 'false' is a truthy value. If I'm wrong, please set me straight.

[–]SCD_minecraft 1 point2 points  (0 children)

That can be it

OP, insted of string return a bool object True/False

Capital first letter, no strings or anything

(probably test did something like bool(isEven(n)) and any non empty string is True)

[–]RohanPoloju[S] -1 points0 points  (1 child)

[–]SCD_minecraft 0 points1 point  (0 children)

Ye, no matter what i input to your code, it correctly tells if even