How do I repeat each element of a list n
times and form a new list? For example:
x = [1,2,3,4]
n = 3
x1 = [1,1,1,2,2,2,3,3,3,4,4,4]
x * n
doesn't work
for i in x[i]:
x1 = n * x[i]
There must be a simple and smart way.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…