nums = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
roman = ['M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I']
def from_roman_numeral(roman_numeral):
result = 0
if roman_numeral in roman:
result += nums[roman.index(roman_numeral)]
else:
arr = list(roman_numeral)
for i in range(0, len(arr) - 1):
if arr[i] in roman:
if arr[i] >= arr[i + 1]:
result += nums[roman.index(arr[i])]
elif arr[i] <= arr[i + 1]:
result -= nums[roman.index(arr[i])]
print(result)
return result