question roman numerals are represented by seven different symbols i v x l c d and m and their values are 1 5 10 50 100 500 1000 respectively given a roman numeral convert it to an integer input is guaranteed to be within the range from 1 to 3999 example 1 input xi output 11 example 2 input cccxl output 340 source interview question time complexity on space complexity o1 function to convert a roman numeral to an integer getting the value of the symbol comparing if the next value is bigger or smaller than the current value if it is big the value is subtracted from the sum main code function to convert a roman numeral to an integer getting the value of the symbol comparing if the next value is bigger or smaller than the current value if it is big the value is subtracted from the sum main code
def roman_to_integer(input):
    romans={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
    sum=0
    for i in range(input):
        
        value=romans[input[i]]
        
        if i+1<len(input):
            if romans[input[i+1]]>value:
                
                sum-=value
        else:
            sum+=value
    return sum


print("Roman to integer conversion of")
input=input.upper()
roman_to_integer(input)