Advertisement
Guest User

Untitled

a guest
Dec 5th, 2020
1,388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. class Solution:
  2. def intToRoman(self, num: int) -> str:
  3.  
  4. 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}
  5. output = ""
  6. for key, value in sym.items():
  7. temp = num//value
  8. if temp == 0:
  9. continue
  10. else:
  11. num = num%value
  12. output = output +key*temp
  13. if num == 0:
  14. return output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement