Last active
June 12, 2017 19:24
-
-
Save flyte/9781638 to your computer and use it in GitHub Desktop.
Pluralise word (add 's') when i != 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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