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.
XXL is not a correct roman number.
If you mean 30, it is expressed XXX. Only 40 would be expressed as XL, which works fine
are you an arabic my friend
oh man, you are crazy xD
pretty cool stuff
This comment is hidden because it contains spoiler information about the solution
Try "XXL". it doesn't work correctly
Can someone explain why he processes the roman numeral backwards?
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
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.
I enjoy this one for readability and cleverness.
As a beginner, the only two things that I would alter: (1) name of the dict as it overwrites a build-in name and (2) reduce the if/elif/else statement by putting "if last > dict[c] and last == not 0"
Situations like you mentioned ( 3 being writen as 'IIV' ) won't occur since 'IIV' is not a valid roman number (Kata was to create a decoder for VALID roman numbers)
Elegantly put, however, this code fails in situations when two smaller numbers preceed a larger one. Such as 3=IIV, 8=IIX, 300=CCD etc.
(When looking at the roman numeral in reversed order) When the first small number is compared to the larger number, it passes the test for the elif statement and is subtracted. Then the second small numeral is compared to the first small numeral, which it equals, it is added. Therefore, using this code IIV=5, IIX=10, CCD=500 etc.
It's a pity they do not use these examples in the test cases
To fix this last should only be updated in the if and else code blocks
@FArekkusu - A simple "No, I'm sorry if it seemed that way" would have gone much further than another point by point tirade.
I don't mind being corrected and I don't mind admitting when I'm wrong so long as the conversation remains friendly.
Loading more items...