I have two lists:
a = [1,1,1]
b = [[2,2,2],[3,3,3]]
I want to prepend a on b in one line of code to create:
result = [[1,1,1],[2,2,2],[3,3,3]]
I want to also preserve a and b during the process so you cannot just do:
b[:0] = [a]
                Just use concatenation, but wrap a in another list first:
[a] + b
This produces a new output list without affecting a or b:
>>> a = [1,1,1]
>>> b = [[2,2,2],[3,3,3]]
>>> [a] + b
[[1, 1, 1], [2, 2, 2], [3, 3, 3]]
>>> a
[1, 1, 1]
>>> b
[[2, 2, 2], [3, 3, 3]]
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With