-4
L = [[a1,a2,a3...100] , [b1,b2,b3...100]]

I want to append

[[c1,c1,c1..10, c2,c2,c2...10, ..., c10,c10,c10...10].

Is there a way where I can append it using a single line?

L.append([[c1]*10,[c2]*10]...)

The above line causes the appending as sublists. I don't want that.

Is there any way to create a custom list and append it on the fly

Thanks in advance!

Sanjay
  • 3
  • 1
  • 2
    Can you show what you *do* want as a result? – Scott Hunter Sep 13 '19 at 17:38
  • Possible duplicate of [List of lists changes reflected across sublists unexpectedly](https://stackoverflow.com/questions/240178/list-of-lists-changes-reflected-across-sublists-unexpectedly) – ggorlen Sep 13 '19 at 17:41

1 Answers1

-2

Change it to

L.append(sum([[c1] * 10, [c2] * 10], []))

The sum function will concatenate the lists using the + operator

blue_note
  • 27,712
  • 9
  • 72
  • 90