mootfrost-dev/backend/app/utils.py
2023-05-03 21:36:53 +03:00

15 lines
369 B
Python

def declension(num: int, one: str, two: str, five: str):
n = num % 100
if 11 <= n <= 19:
return f'{str(num)} {five}'
else:
i = n % 10
if i == 1:
return f'{str(num)} {one}'
elif i in [2, 3, 4]:
return f'{str(num)} {two}'
else:
return f'{str(num)} {five}'
__all__ = ['declension']