Advertisement
briank

12days.py

Feb 12th, 2013
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. # Python 2
  2.  
  3. lister = ['extra-input to cover the 0',
  4.  'A Partridge in a Pear Tree.',
  5.  '2 Turtle Doves',
  6.  '3 French Hens',
  7.  '4 Colly Birds',
  8.  '5 Golden Rings',
  9.  '6 Geese-a-Laying',
  10.  '7 Swans-a-Swimming',
  11.  '8 Maids-a-Milking',
  12.  '9 Ladies Dancing',
  13.  '10 Lords-a-Leaping',
  14.  '11 Pipers Piping',
  15.  '12 Drummers Drumming']
  16.  
  17. nth = ['th', 'st', 'nd', 'rd']
  18.  
  19. # Recursively print individual verses
  20. def verse (n):
  21.     if 1 <= n <= 12:
  22.         print lister[n]
  23.         if n == 2: print "And",
  24.         verse(n - 1)
  25.  
  26. # Recursively print the carol from the starting verse
  27. def carol (n):
  28.     if 1 <= n <= 12:
  29.         print "On the %d%s day of Christmas, my true love gave to me..." % (
  30.           n, nth[n if n < 4 else 0])
  31.         verse(n)
  32.         print ""
  33.         carol(n - 1)
  34.  
  35. what_verse = int(raw_input('What verse (1-12) do you want? '))
  36. carol(what_verse)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement