The Twelve Days | Of Christmas [v12]

## Day 4 - Four Calling Birds - Three French Hens - Two Turtle Doves - And a Partridge in a Pear Tree

## Day 2 - Two Turtle Doves - And a Partridge in a Pear Tree The Twelve Days of Christmas [v12]

@staticmethod def day_to_text(day): days = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"] return days[day - 1] ## Day 4 - Four Calling Birds -

def recite_song(self): """Recite the entire Twelve Days of Christmas song.""" for i in range(1, 13): print(f"On the {self.day_to_text(i)} day of Christmas, my true love gave to me:") print(self.recite_day(i)) print() # Empty line for readability The Twelve Days of Christmas [v12]

## Day 3 - Three French Hens - Two Turtle Doves - And a Partridge in a Pear Tree

A festive song, refactored for code-readability and ease of modification. ## Day 1 - A Partridge in a Pear Tree

def recite_day(self, day): """Recite the gifts for a given day.""" output = [] for i in range(day, 0, -1): if i == 1 and day != 1: output.append("And " + self.gifts[i - 1]) else: output.append(self.gifts[i - 1]) return "\n".join(output)