Say I have a Python list like this:
letters = ['a','b','c','d','e','f','g','h','i','j']
I want to insert an 'x' after every nth element, let's say three characters in that list. The result should be:
letters = ['a','b','c','x','d','e','f','x','g','h','i','x','j']
I understand that I can do that with looping and inserting. What I'm actually looking for is a Pythonish-way, a one-liner maybe?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…