Roman numeral to integer - Solutions
Exercise 1
Solution
A function that converts a roman numeral to an integer
Shorter but less explicit solution
The code above can be shortened by using less variables and by replacing the nested if statements with a more elaborate condition. The line continuation character \ within the condition is used here to avoid a very long line of code. Another option would be to enclose the condition in round brackets ().
A function that converts a roman numeral to an integer - shorter but less explicit version
Exercise 2
Solution
A function that converts a roman numeral to an integer
Shorter but less explicit solution
A function that converts a roman numeral to an integer - shorter but less explicit version