john
john

Reputation: 81

How to add two lists together to make a list of lists?

If I have lists [1,2,3] and [4,5,6] how can I make a list of lists [[1,2,3],[4,5,6]]?

When I ran a.append(b) with a = [1,1,1] and b = [1,2,4] I got [1, 1, 1, [1, 2, 4]]

I would like [[1,1,1],[2,2,4]]

Upvotes: 0

Views: 64

Answers (2)

sebenalern
sebenalern

Reputation: 2559

declare

a = [1,1,1]
b = [1,2,4]
c = []

c.append(a)
c.append(b)

Upvotes: 0

fonfonx
fonfonx

Reputation: 1465

What about

newlist=[a,b]

if a=[1,2,3] and b=[4,5,6]?

Upvotes: 4

Related Questions