Skip to content
Snippets Groups Projects
Commit bebc650f authored by Muhamed's avatar Muhamed
Browse files

test 21

parent a7bc2f57
No related branches found
No related tags found
No related merge requests found
Pipeline #19976 failed
......@@ -3,11 +3,13 @@
import unittest
def convert(n: int) -> str:
if n == 1:
return "I"
if n == 10:
return "X"
return ""
roman_numerals = {10: "X", 1: "I"}
result = ""
for value in sorted(roman_numerals.keys(), reverse=True):
while n >= value:
result += roman_numerals[value]
n -= value
return result
class TestRomanConverter(unittest.TestCase):
def test_1(self):
......@@ -15,6 +17,8 @@ class TestRomanConverter(unittest.TestCase):
def test_10(self):
self.assertEqual(convert(10), "X") # Erwartet "X" für 10
def test_21(self):
self.assertEqual(convert(21), "XXI") # Erwartet "XXI" für 21
if __name__ == "__main__":
unittest.main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment