DEV Community

Cover image for Twelve Days of Christmas
Hai Vu
Hai Vu

Posted on

2 1

Twelve Days of Christmas

Here is a fun bit: I wrote a little Python script to displays the lyric of Twelve Days of Christmas in 12 lines.

#!/usr/bin/env python3
gifts = [
    'a partridge in a pear tree', 'two turtle doves and', 'three French hens',
    'four calling birds', 'five gold rings', 'six geese a-laying',
    'seven swans a-swimming', 'eight maids a-milking', 'nine ladies dancing',
    'ten lords a-leaping', 'eleven pipers piping', 'twelve drummers drumming'
    ]
days = """first second third fourth fifth sixth seventh eighth
    ninth tenth eleventh twelfth""".split()
for limit, day in enumerate(days, 1):
    gift = '\n  '.join(reversed(gifts[:limit]))
    print(f'On the {day} day of Christmas, my true love gave to me\n  {gift}\n')
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay