Skip to content

Instantly share code, notes, and snippets.

@danudey danudey/
Last active Aug 29, 2015

What would you like to do?
Twelve lines of Christmas
#!/usr/bin/env python
gifts = ("partridge in a pear tree", "turtle doves", "french hens",
"calling birds", "golden rings", "geese-a-laying", "swans-a-swimming",
"maids-a-milking", "ladies dancing", "lords-a-leaping", "pipers piping",
"drummers drumming",)
for i in xrange(1,len(gifts)+1):
print "On the {} day of Christmas, my true love gave to me:".format(
str(i)+("th" if 4<=i%100<=20 else {1:"st",2:"nd",3:"rd"}.get(i%10, "th")))
for j, gift in list(enumerate(gifts[:i],1))[::-1]:
print " {} {}".format((j,("and a","a")[i==1])[j==1], gift)

This comment has been minimized.

Copy link
Owner Author

danudey commented Dec 20, 2014


  1. Fits in twelve lines
  2. Fits in 80 chars/line (but only because I use two-space indents)
  3. Ugly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.