def fromRoman(strng):
    """convert Roman numeral to integer"""
    if not strng:
        raise TypeError('Input can not be blank')
    if not romanNumeralPattern.search(strng):
        raise ValueError('Invalid Roman numeral: %s', strng)

    result = 0
    index = 0
    for numeral, integer in romanNumeralMap:
        while strng[index:index+len(numeral)] == numeral:
            result += integer
            index += len(numeral)
    return result
convert Roman numeral to integer