Codewars Python in its 6kyu Kata has given us a problem to convert an integer into the Roman numeral Symbols. In Ancient Roman times, people use Roman numbers instead of integers.
My approach to the Problem:
Firstly, I made two Lists in Python, first to store the Numbers which have a Single Roman Symbol Available and Second List for Roman Symbols.
To Find the Solution Read
https://hecodesit.com/codewars-python-integer-to-roman-conversion/
For further actions, you may consider blocking this person and/or reporting abuse
Discussion (7)
I came up with this solution
from enum import Enum
class Roman(Enum):
M = 1000
D = 500
C = 100
L = 50
X = 10
V = 5
I = 1
def convert_number_to_roman(number: int) -> str:
result = ""
while number > 0:
for roman in Roman:
while number - roman.value >= 0:
number -= roman.value
result += roman.name
return result
Really Helpful
From a short glance on your code, I wonder if you considered usage of Python built-in divmod.
Hey, Thank You so Much, Just read about this function, will apply in future.
Why does you image say "1, 2, 3, 4, 5, 6, 8, 8, 9, 10, 11, 12" ?
It was a Codewar Kata to Convert Integers into Roman Numbers in Python