on-internet
← Community

Why is my code not adding the last character when converting Roman numerals?

Stack Overflow ·

I'm trying to create a Roman numeral converter. My code compares two consecutive characters to determine whether the first value should be subtracted or added, following the Roman numeral rules. However, I'm having a problem: the last character entered by the user is not being added to the final result. For example, when I enter XV, the expected result is 15, but my code does not add the last character (V) correctly. I tried using len() to control the loop and check the position of each character, but I still haven't figured out how to solve this problem. Why is the last character not being ad

Comments

Sign in or sign up to comment and upvote.

No comments yet.