-1

i'm trying to concatenate a list with itself, but it needs to be a specific number of times

list1=[1,2,3,4]
list2=(list1+list1+list1)
print(list2)
#output would be [1,2,3,4,1,2,3,4,1,2,3,4]

but i want the list to be concatenated with itself a user specified number of times, not just the example of 3

  • 1
    Welcome to Stack Overflow! Check out the [tour] and [ask]. Stack Overflow is not a code-writing service, but if you write your own code and have problems, you're welcome to ask here. You know that you need to take input from the user, so what's stopping you? Do you know how to convert a string to an int? Do you know how to multiply a list? – wjandrea Feb 11 '20 at 20:05

1 Answers1

1
list1=[1,2,3,4]
mult = 5
list2 = list1 * mult

Resulting list2:

[1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
Prune
  • 76,765
  • 14
  • 60
  • 81