I want two lists inside one list:
x = [1,2]
y = [3,4]
I need them to turn out like:
z = [[1,2][3,4]]
But I have no idea how to do that. Thanks so much for your consideration and help.
I want two lists inside one list:
x = [1,2]
y = [3,4]
I need them to turn out like:
z = [[1,2][3,4]]
But I have no idea how to do that. Thanks so much for your consideration and help.
 
    
    Make a new list which contains the first two lists.
z = [x, y]
This will make each element of z a reference to the original list. If you don't want that to happen you can do the following.
from copy import copy
z = [copy(x), copy(y)]
print z
 
    
    If you don't want references to the original list objects:
z = [x[:], y[:]]
 
    
    This will work:
 >>> x = [1, 2]
 >>> y = [3, 4]
 >>> z = [x, y]
 >>> print("z = ", z)
 z =  [[1, 2], [3, 4]]
x = [ 1, 2 ]
y = [ 2, 3 ]
z =[]
z.append(x)
z.append(y)
print z
output:
[[1, 2], [2, 3]]
