Ad
Basic Language Features
Fundamentals
Control Flow
Code
Diff
  • def convert_decimal_roman(number):
        number = int(number)
        str = ''
        numDct = {1000: "M",
                  900: "CM",
                  500: "D",
                  400: "CD",
                  100: "C",
                  90: "XC",
                  50: "L",
                  40: "XL",
                  10: "X",
                  9: "IX",
                  5: "V",
                  4: "IV",
                  1: "I"}
        
        for key, value in numDct.items():
            str += value * (number // key)
            number %= key
            
        return str
    • def convert_decimal_roman(number):
    • number = int(number)
    • str = []
    • str = ''
    • numDct = {1000: "M",
    • 900: "CM",
    • 500: "D",
    • 400: "CD",
    • 100: "C",
    • 90: "XC",
    • 50: "L",
    • 40: "XL",
    • 10: "X",
    • 9: "IX",
    • 5: "V",
    • 4: "IV",
    • 1: "I"}
    • for key, value in numDct.items():
    • str.append(value * (number // key))
    • number = number % key
    • str += value * (number // key)
    • number %= key
    • return "".join(str)
    • return str