def romanToNumber(numerals):
    '''Converts a string of Roman Numerals (I,V,X,L,C,D,M) into an integer.'''

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

    ### Build List of Numbers ###
    
    numberList = []
    for letter in numerals:
        # Build List of Numbers
        if letter in romanConversionTable:
            numberList += [romanConversionTable[letter]]
        else:
            raise IllegalCharacterError('{} is not a Roman Numeral'.format(letter))

    if len(numberList) == 1:
        return numberList[0]

    ### Construct Final Total ###

    previous = numberList[-1]
    total = previous
    for current in range(len(numberList)-2,-1, -1):
        if numberList[current] < previous:
            total -= numberList[current]
        else:
            total += numberList[current]
        previous = numberList[current]

    return total
Converts a string of Roman Numerals (I,V,X,L,C,D,M) into an integer.
recipes/Python/580731_Roman_Numeral_Converter/recipe-580731.py