Skip to content

Instantly share code, notes, and snippets.

@Blucknote
Forked from CubexX/plural.py
Last active August 26, 2019 12:33
Show Gist options
  • Save Blucknote/ae447b2b6be7f4cba9b801b30d9524f7 to your computer and use it in GitHub Desktop.
Save Blucknote/ae447b2b6be7f4cba9b801b30d9524f7 to your computer and use it in GitHub Desktop.
Python abstract plural
def pluralize(n, lst):
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 '{} {}'.format(str(n), lst[p])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment