Randomly Generated Poetry in Python

I love import random. It’s the only uncertainty I really enjoy in my life. Along with a single line for loop it’s one of the things I’ve kind of mastered (ehm) when learning Python. Also, combining technology and language is fun! Yes, it’s just a few lines of very novice code but I love it anyway. 🙂 

All you need is lov… no, a list.txt

At first, I wanted to generate poems in Czech, then – realizing all the grammar nazi problems ahead – I switched to English. No difficulties with tense and gender related endings.

For a start, I found a list of 3000 most common English words. As grammar rules for poetry are more liberate, I paid no attention to articles, proper tense, syntax or anything at all, actually.

I let the script randomly pick 10 words. The first one, in uppercase, is a title. The other nine words are then divided 3 x 3, first word in line always capitalized.

That’s almost all it can do. Just writing (and saving!) a short dada-ish poem.

Here, you can find it on my GitHub and generate a poem (or a super cool thought for a motivational poster) for yourself.

Leave a Comment

Your email address will not be published. Required fields are marked *