pycnnum icon indicating copy to clipboard operation
pycnnum copied to clipboard

num2cn gives an error for input integer 101.

Open aroitman opened this issue 6 years ago • 2 comments

for example, the output for the command: pycnnum.num2cn(101) is

File "", line 1, in File "/home/example/.local/lib/python3.6/site-packages/pycnnum/pycnnum.py", line 282, in num2cn result_symbols = get_value(int_string) File "/home/example/.local/lib/python3.6/site-packages/pycnnum/pycnnum.py", line 268, in get_value return get_value(result_string) + [result_unit] + get_value(striped_string[-result_unit.power:]) File "/home/example/.local/lib/python3.6/site-packages/pycnnum/pycnnum.py", line 268, in get_value return get_value(result_string) + [result_unit] + get_value(striped_string[-result_unit.power:]) File "/home/example/.local/lib/python3.6/site-packages/pycnnum/pycnnum.py", line 260, in get_value return [system.digits[0] * (len(value_string) - len(striped_string)), system.digits[int(striped_string)]] TypeError: unsupported operand type(s) for *: 'ChineseNumberDigi' and 'int'

here I changed my username with "example"

aroitman avatar Aug 21 '19 02:08 aroitman

Indeed, It looks like the function doesnt work for any number with a "0" in it, that is not at the tail-end. For example, 1821010 doesnt work 111180000 does work

aroitman avatar Aug 21 '19 02:08 aroitman

I made my attempt with the replacement of the following, from: return [system.digits[0] * (len(value_string) - len(striped_string)), system.digits[int(striped_string)]] to return [system.digits[0], system.digits[int(striped_string)]]

that is, no need for multiplication (and that is invalid as well as shown in error message).

azhu26 avatar Jul 25 '20 22:07 azhu26

Fixed in the coming release

zeicold avatar Jun 01 '24 22:06 zeicold