Skip to content

Instantly share code, notes, and snippets.

@youmee
Last active December 22, 2020 19:03
Show Gist options
  • Save youmee/8e24a7d7ffe39a2a9fa4e452ea6a58ea to your computer and use it in GitHub Desktop.
Save youmee/8e24a7d7ffe39a2a9fa4e452ea6a58ea to your computer and use it in GitHub Desktop.
def plural_form(number: int, forms: list[str]) -> str:
"""
Returns correct plural form for Russian Language
:param number: 33
:param forms: ["год", "года", "лет"]
:return: года
"""
if number % 10 == 1 and number % 100 != 11:
return forms[0]
elif 2 <= number % 10 <= 4 and (number % 100 < 10 or number % 100 >= 20):
return forms[1]
else:
return forms[2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment