Skip to content

Instantly share code, notes, and snippets.

@imgVOID
Forked from CubexX/plural.py
Created January 20, 2022 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imgVOID/528b36e58454c802475138931d600922 to your computer and use it in GitHub Desktop.
Save imgVOID/528b36e58454c802475138931d600922 to your computer and use it in GitHub Desktop.
Python plural russian days / Склонение день/дня/дней
def plural_days(n):
days = ['день', 'дня', 'дней']
if n % 10 == 1 and n % 100 != 11:
p = 0
elif 2 <= n % 10 <= 4 and (n % 100 < 10 or n % 100 >= 20):
p = 1
else:
p = 2
return str(n) + ' ' + days[p]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment