leetcode Integer to Roman python

class Solution(object):
    def intToRoman(self, num):
        """
        :type num: int
        :rtype: str
        """
        if num > 3999 or num < 1:
            return ""
        values = [1000,900,500,400,100,90,50,40,10,9,5,4,1]
        numerals = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]
        lists=''
        for i in range(0,len(values)):
            while num >= values[i]:
                num -= values[i]
                lists += numerals[i]
        return lists
        

@link http://www.cnblogs.com/zuoyuan/p/3779581.html

posted @ 2015-11-18 22:35  hao.ma  阅读(129)  评论(0编辑  收藏  举报