Skip to content

Instantly share code, notes, and snippets.

@flyte
Last active June 12, 2017 19:24
Show Gist options
  • Save flyte/9781638 to your computer and use it in GitHub Desktop.
Save flyte/9781638 to your computer and use it in GitHub Desktop.
Pluralise word (add 's') when i != 1
In [1]: s = lambda i: "s"[i==1:]
In [2]: for i in range(0, 5):
...: print "I have %d apple%s" % (i, s(i))
...:
I have 0 apples
I have 1 apple
I have 2 apples
I have 3 apples
I have 4 apples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment