Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def intToRoman(self, num: int) -> str:
- sym = {"M":1000,"CM":900,"D":500,"CD":400,"C":100,"XC":90,"L":50,"XL":40,"X":10,"IX":9,"V":5,"IV":4,"I":1}
- output = ""
- for key, value in sym.items():
- temp = num//value
- if temp == 0:
- continue
- else:
- num = num%value
- output = output +key*temp
- if num == 0:
- return output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement