Skip to content

Instantly share code, notes, and snippets.

@gregsonar
Last active December 27, 2016 12:13
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 gregsonar/dc66092a0a8a88d0388d70cc5b9b7170 to your computer and use it in GitHub Desktop.
Save gregsonar/dc66092a0a8a88d0388d70cc5b9b7170 to your computer and use it in GitHub Desktop.
Скрипт для правильной подстановки слова после числа (1 день, 3 дня, 12 дней и т.д.)
def plurals(n):
n = abs(n)
n %= 100
n1 = n % 10
if 20 < n > 10:
form = 'баллов'
elif 5 > n1 > 1:
form = 'балла'
elif n1 == 1:
form = 'балл'
else:
form = 'баллов'
return "{} {}".format(n, form)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment