For example, if I have:
A = [1, 2, 3]` & `B = [4, 5, 6]
and I would like to have:
C = [[1, 4], [2, 5], [3, 6]]
You can use tuple and zip to meet this requirement.
Sample code -
>>> a = [1,2,3]
>>> b = [4,5,6]
>>> c = tuple(zip(a,b))
>>> print(c)
((1, 4), (2, 5), (3, 6))
There is a builtin function called zip for this:
[list(ab) for ab in zip(a,b)]
Or using map and zip:
list(map(list, zip(a,b)))
Both return:
[[1, 4], [2, 5], [3, 6]]
You can do this:
a = [1,2,3]
b = [4,5,6]
c = [list(x) for x in zip(a, b)]
In [110]: A = [1,2,3]
In [111]: B = [4,5,6]
In [112]: list(zip(A,B))
Out[112]: [(1, 4), (2, 5), (3, 6)]