I want to duplicate a list n number of times while preserving the order of the list itself. For example all I have right now and it doesn't work nor does it give me an error.
def duplicate(testList, n):
y = 0
x = len(testList)
newList=[]
while y < x:
for z in range (0, n):
newList.append(testList[y])
y = y + 1
return newList
duplicate([1,2,3], 3)
After this im not sure where to fix it.
The desired output is:
[1,1,1,2,2,2,3,3,3]