Convert romain numeral strings to integer outputs

Question

Write a function that will input a roman numeral and return the integer output. Your function will only need to deal with a max input of 3,999. Additionally, you can reference the following dictionary for conversions:

{"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000}

For example:

"CCVII" -> returns 207
"VII" -> returns 7

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now