Write a program to insert elemnet in the list after every nth element


Topic: Write a program to insert elemnet in the list after every nth element

Solution

letters = ['a','b','c','d','e','f','g','h','i','j']
i = 3
while i < len(letters):
    letters.insert(i, 'x')
    i += 4
letters



List all Python Programs