Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- short = {0: '',
- 1: 'тыс.',
- 2: 'млн.',
- 3: 'млрд.',
- 4: 'трлн.',
- 5: 'тлрд.',
- 6: 'квадрлн.',
- 7: 'квадрд.',
- 8: 'квинтлн.',
- 9: 'квинтрд.',
- 10: 'секстлн.',
- 11: 'секстрд.',
- 12: 'септлн.',
- 13: 'септрд.',
- 14: 'октлн.',
- 15: 'октрд.',
- 16: 'нонилн.',
- 17: 'нонирд.'}
- def to_human(money, after_round=True, round_number=2, sep='\''):
- money = str(money).split(sep='.')
- before = money[0]
- if len(money) > 1:
- after = money[1]
- index = -1
- string = ''
- for i in before[::-1]:
- if index < 2:
- string += i
- index += 1
- else:
- string += sep
- string += i
- index = 0
- return f'{string[::-1]}{f".{after if not after_round else after[:round_number]}" if len(money) > 1 else ""}'
- numbers = ['100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000', '10000000000',
- '100000000000', '1000000000000']
- sep = "'"
- for i in numbers:
- print(f'{to_human(i).split(sep=sep)[0]} {short[len(i) // 3] if len(i) % 3 != 0 else short[(len(i) // 3) - 1]}')
Advertisement
Add Comment
Please, Sign In to add comment