chore: added comments

This commit is contained in:
Sandro Zimmermann 2026-03-24 18:07:36 +01:00
parent 1c2f806960
commit 25bc41726e

View File

@ -30,11 +30,20 @@ D = {2: 10, 3: 100, 4: 1000, 5: 10000}
def to_chinese_numeral(n):
# Check if n in C dictonary
try:
return C[n]
except KeyError:
pass
# Check if negative
if n < 0:
n = abs(n)
is_negative = True
else:
is_negative = False
# Put single digits in list
split_number = [int(x) for x in str(n)]
arranged_number = []
@ -46,7 +55,10 @@ def to_chinese_numeral(n):
if arranged_number[-1] == 0:
arranged_number.pop(-1)
if is_negative:
arranged_number.append("-")
return arranged_number
print(to_chinese_numeral(120))
print(to_chinese_numeral(-90909)) # 9 10000 9