Skip to content
Advertisement

python: most elegant way to intersperse a list with an element

Input:

JavaScript

Output:

JavaScript

What’s the most elegant (read: Pythonic) way to write intersperse?

Advertisement

Answer

I would have written a generator myself, but like this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement