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(len(arr) - 1):
            if arr[i] >= arr[i + 1]:
                result += nums[roman.index(arr[i])]
            else:
                result -= nums[roman.index(arr[i])]
    print(result)
    return result
    
from_roman_numeral("V")
from_roman_numeral("XX")
from_roman_numeral("DCCC")
from_roman_numeral("MMMM")