Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+3 votes

I keep thinking that I've got the answer right, but I keep getting the message that
"None should equal 1", "none should equal 3.5", etc... and I think those are the answers that I'm supposed to be getting but there's no tutorial (that I could find).

Has anyone else played with code wars that can explain what it means?

asked in CSC201 Spring 2021 by (1 point)

1 Answer

+4 votes

Hi Elizabeth,
Do you mean this Code wars https://www.codewars.com/?
Can you be more specific about the problem?

answered by (1 point)
+1

Yes, and it's just the first one that popped up for me that says:
This code does not execute properly. Try to figure out why.
>>>def multiply(a, b):
>>> a * b

and the errors pop up as
"None should equal 1", "none should equal 3.5"

Don't give me any hints on the code!!!!!
I just want to know what the "none should equal' means

+1

In order for the platform to validate your outcome, like in moodle, you need to print or return the result by the end of the function. It got None because you didn't show them the outcome.

+1

Yeah, I got that far... even when I print it though, it still says "none should equal {}" (and then it'll put the output under) but what is none???
I think it might just mean output?
Also this one is really tough because now I also have to change the equation on top of changing the code because all of the answers are different from what they would be if it was a*b!
Codewars is a lot tougher than I thought it would be @.@

+1

No, I think you approach the problem really well. Try return the result instead of print. For example:

return a + b

The reason why it has to be return because they need to put your result into the test function to validate if you are right or wrong. If you use print, they cannot get your result. Hence they show None

+1

Yes, we're going to learn about the RETURN statement on Friday! (Or you can read ahead in the book...Section 6.5)

...