Skip to content

Commit

Permalink
Roman Numeral Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Brisinger committed Jul 13, 2024
1 parent 3997c16 commit 26dce2b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/pyBootCamp/romanconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,12 @@
unit = 1 # One's place initially.
while number:
"""Gather successive digits in the number from right to left.
Modulo operator evaluates to a float type.
Convert the value of the operation to int type before storing it in variabe digit.
The variable digit is used in integer division with is not compatible with float types.
"""
digit = int(number % 10) * unit
digit = (number % 10) * unit
if digit == 0:
# Unit placeholder one's, ten's, hundered's and thousand's place in an integer.
unit *= 10
number /= 10
number //= 10
continue
elif digit > 0 and digit < 4:
result = roman[1] * digit + result
Expand All @@ -60,7 +57,7 @@
elif digit == 90:
result = roman[digit] + result
elif digit >= 100 and digit < 400:
result = roman[100] * (digit // unit) * result
result = roman[100] * (digit // unit) + result
elif digit == 400:
result = roman[digit] + result
elif digit >= 500 and digit < 900:
Expand All @@ -72,5 +69,5 @@
# Multiply the placeholder by 10 to represent the next digit in the number.
unit *= 10
# remove the digits from the number from right to left.
number /= 10
number //= 10
print(result)

0 comments on commit 26dce2b

Please sign in to comment.