feat: will now return numerals from 0 to 19 correctly
This commit is contained in:
parent
81b25abc2b
commit
a5e72e9402
39
src/codewars/kata_chinese_numeral_encoder.py
Normal file
39
src/codewars/kata_chinese_numeral_encoder.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
C = {
|
||||||
|
"-": "负",
|
||||||
|
".": "点",
|
||||||
|
0: "零",
|
||||||
|
1: "一",
|
||||||
|
2: "二",
|
||||||
|
3: "三",
|
||||||
|
4: "四",
|
||||||
|
5: "五",
|
||||||
|
6: "六",
|
||||||
|
7: "七",
|
||||||
|
8: "八",
|
||||||
|
9: "九",
|
||||||
|
10: "十",
|
||||||
|
100: "百",
|
||||||
|
1000: "千",
|
||||||
|
10000: "万",
|
||||||
|
11: "十一",
|
||||||
|
12: "十二",
|
||||||
|
13: "十三",
|
||||||
|
14: "十四",
|
||||||
|
15: "十五",
|
||||||
|
16: "十六",
|
||||||
|
17: "十七",
|
||||||
|
18: "十八",
|
||||||
|
19: "十九",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def to_chinese_numeral(n):
|
||||||
|
try:
|
||||||
|
return C[n]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return 10
|
||||||
|
|
||||||
|
|
||||||
|
print(to_chinese_numeral(20))
|
||||||
Loading…
x
Reference in New Issue
Block a user