Advertisement
superpawko

Untitled

Oct 8th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. def checkio(data):
  2. roman_dict = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000}
  3.  
  4. def dig_to_roman(data, result):
  5. if data > roman_dict["M"]:
  6. print(data)
  7. dig_to_roman(data-roman_dict["M"], result + "M")
  8. else:
  9. #print("PRINT RESULT ", result)
  10. return result
  11.  
  12.  
  13. return dig_to_roman(data, "")
  14. # if __name__ == '__main__':
  15. # #These "asserts" using only for self-checking and not necessary for auto-testing
  16. # assert checkio(6) == 'VI', '6'
  17. # assert checkio(76) == 'LXXVI', '76'
  18. # assert checkio(499) == 'CDXCIX', '499'
  19. # assert checkio(3888) == 'MMMDCCCLXXXVIII', '3888'
  20. print(checkio(4888))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement