# Days of Christmas problem # Subroutine to output the twelve days of Christmas using a nested iteration def OutputSong(): Day = ["first", "second", "third", "fourth", "fifth"] Item = ["partridge in a pear tree", "Two turtle doves","Three french hens", "Four calling birds", "Five gold rings"] Verse = 0 ReverseVerse = 0 # Output each verse for Verse in range(len(Day)): print("On the {} day of Christmas".format(Day[Verse])) print("My true love gave to me") # All the items from the previous verses are output for ReverseVerse in range(Verse, 0, -1): # Output only one partridge! if ReverseVerse > 0: print(Item[ReverseVerse]) # Needs an 'A' or 'And' prefix depending on the verse if Verse == 0: print("A",Item[0]) else: print("And a", Item[0]) print() # Main program OutputSong()