mootfrost-dev/backend/app/utils.py
2023-05-02 14:38:03 +03:00

12 lines
342 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}'