I have 3 Lists
a= [1,2,3]
b= [4,5,6]
c= []
Am trying to create
c = [[1,2,3],[4,5,6]]
I know c.append(a)
followed by c.append(b)
does the job. But is it possible to do it in a single line ?
Or any other method to "include" multiple list to one list so that we get a nDimensional list?
Or resort to numpy
?
NOTE: Merging/Concatenating the lists using zip
or extend
or using " " is not what am looking for
CodePudding user response:
You can use the extend
method to achieve what you want.
Code:
a = [1, 2, 3]
b = [4, 5, 6]
c = []
c.extend([a, b])
print(c)
Output:
>>> python3 test.py
[[1, 2, 3], [4, 5, 6]]