-2

suppose I have a list

a = [1,2,4,5]

I want to create another list b which clones a and adds it 3 times. So b is expected to be

b = [1,2,4,5,1,2,4,5,1,2,4,5]

How do I do this easily? Methods using pandas or numpy is also welcome.

martineau
  • 119,623
  • 25
  • 170
  • 301

1 Answers1

0
#just use the * operator
b=a*3
ibadia
  • 909
  • 6
  • 15