Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Hi.
I have the same error message, I have no idea what's the problem. Some suggestion?
Ok, it is fine. I pass the kata only clearing the cache. Thanks a lot for your help!!
I do not know. Try clearing the cache or something. I tried your code with example test samples in Py3.60 and it passed all of them, including the
-10/7
.Ok, thanks for your debugging! It is correct and it was I supposed initially, your code was written in Py2, and my code is in Py3. So, I have tried to execute with Py 3.60, but the results are the same, and the error messages are the same. Do I have to change something o activate some check in the kata to refresh your test code in Py3 and not in Py2?
Okay, I see the problem. I wrote this kata long ago when only Python2 was supported, therefore it was available in Python2 only. You wrote your code for Python3 and tried using it in Python2, but difference between versions of the language made it produce wrong result.
Now I created a version for Python 3.60. Try choosing Python 3.60 in trainer instead of Python 2.7 and see if your code works there.
Or you may still try to adapt your code for Python 2 and gain some experience in understanding how it is different from Python 3.
Dear Rhuergo! Are you sure you've chosen the correct version of Python? I've tested your code in repl.it. Your code does not give correct results in Python 2, but produces correct output for "-10/7" in Python 3 there. Make sure you choose the correct implementation here, as several versions of Python are available and they may have differences - e. g. in Python 3 single slash is float division by default, but in Python 2 it defaults to integer division.
Once again, you can see how your code behaves here by inserting
print(p_entera, numerador, denominador)
before your last if-(if-else)-else block.Sincerely, I can't understand anyway why I have to change my code, to have the same results that the tests give, when my code is still giving these correct results. Sorry for my insistence, I am very confused. Maybe in your test, you have distinct results executing my code, but in Py3, the results of executing my code are correct, but the error messages are wrong. So hard to accept!
Ok, thank you for the tip. However, it is not a good new for me, because I am working with Py3, as you know. But, it doesn't matter, I will keep pushing!
Rhuergo, looks like Python interger division with negative numbers works not the way you expect, hence the problem. It floors the result, therefore in Py2
-10/7
evaluates to-2
. Meanwhile, you expect it to ceil the result if the result is negative. This is what causes problems in your solution. You have to find a workaround.Another tip: you can always use
print
to show yourself the value of variable(s) at certain stage. Use it to debug your solution. It helps a lot.Oh my god, sorry. I had forgot it!! :-(
spoiler flags! x/
This comment is hidden because it contains spoiler information about the solution
Please show your code. The statement
'-2 4/7' should equal '-1 3/7'
means that your code actually returns-2 4/7
.This comment is hidden because it contains spoiler information about the solution
12876 / 17030 != 31 / 41
Loading more items...