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.
are you an arabic my friend
OP solved it, closing
My solution found isPP(92429 ** 10) in 4 loops.
It is a waste of time in the sense that you are at best trying to rely on undefined behaviour, but I don't think the version is the difference at all, but rather that you are running the test differently.
0.0 is 0.0
typically evaluates toTrue
, but if you obtain0.0
from two different modules those may be separate values.Testing whether you receive THE SAME ONE
0.0
is a very very strange thing and probably isn't even what you mean to do.What you're supposed to test is whether both are
0.0
, not whether they're the same0.0
0
happens to be different only because cpython keeps a single instance of it. you still shouldn't make that comparison though.Maybe this could be useful: https://www.tutorialspoint.com/execute_python3_online.php it uses 3.6.2
As my comment is marked as spoiler, I cannot see it anymore. But I will try to remember what I wrote.
It worked in codewars with all tests but the one with 0 and 0.0. Then I tried the one that failed (with 0 and 0.0) in pycharm with 3.8 to find out what was wrong and it worked.
I was reading the "what's new in Python 3.8" documentation to understand, but I realised it would take a lot of time to read (and specially understand) everything.
I was thinking about installing the 3.6 version to make some tests with pycharm, because it gives a lot of clues, to understand the problem.
Do you think it is a good approach or a waste of time?
Thank you for your time.
This does not pass all tests with 3.8, maybe you mean some tests but some is not all.
In particular, python does not promise that there exists only one
0
and one0.0
. For cpython this is true for0
(though the language does not promise it, so you shouldn't) but is not true for0.0
so you both shouldn't and can't.Found the problem. I should have used "except IndexError:"
I did not even know the error could be specified. I am reading a book were the guy uses bare except. I will stop reading it. hahaha
This comment is hidden because it contains spoiler information about the solution
Your warning message provides a reference that you can google to answer your own question.
I am a begginer, but I think it is not necessary to create a list.
I solved it with a index counter and used try/except to deal with the last letter. However, pycharm says "too broad exception clause/ PEP 8: E722 do not use bare 'except'".
Can someone explain why it is not best pŕactices and why the exception is too broad?
I think dict[c-1] raises an error, since c is 'str' and 1 is 'int'.
But I think you meant roman.index[c-1] because I tried this. It did not work because in 'MCMXC', for example, on the second 'M' c is stored as 'M' in memory. Then it will search for the index of 'M' and find the first one, which is 0.