Mystery längs 26:an #222

Mystery längs 26:an #222

def printroman(num):
    m = ["", "M", "MM", "MMM", "MMMM", "MMMMM"]
    c = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"]
    x = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"]
    i = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"]
    # Converting to roman
    thousands = m[num // 1000]
    hundreds = c[(num % 1000) // 100]
    tens = x[(num % 100) // 10]
    ones = i[num % 10]
    return thousands + hundreds + tens + ones


j = 0
for i in range(1, 5445):
    roman = printroman(i)
    # print (roman)
    if roman == roman[::-1]:
        j += 1
        print(str(j) + ": " + roman)
print("Antal: " + str(j) + " roman: " + printroman(j))