1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/python
#########################
# #
# Twelve days of xmas #
# Recursive #
# in Python #
# #
# by x1101 #
# x1101@gmx.com #
#########################
DAYS = [
["First","A partridge in a pear tree"],
["Second","Two turtle doves \nand"],
["Third","Three French hens"],
["Fourth","Four calling birds"],
["Fifth","FIVE GOLDEN RINGS"],
["Sixth","Six geese a-laying"],
["Seventh","Seven swans a-swimming"],
["Eighth","Eight maids a-milking"],
["Ninth","Nine ladies dancing"],
["Tenth","Ten lords a-leaping"],
["Eleventh","Eleven pipers piping"],
["Tewlveth","Twelve drummers drumming"]
]
NumDay=0
def give(NumDay, gift, day):
gift += DAYS[NumDay][1]
gift += "\n"
if(NumDay==0):
print "On the",day,"Day of Christmas my ture love gave to me: \n",gift
print ""
else:
give(NumDay-1,gift,day)
while (NumDay <12):
day = DAYS[NumDay][0]
give(NumDay,"",day)
NumDay += 1
|