-1

So I have two lists right now.

list1 = ['A', 'B', 'C', 'D']
list2 = [1, 2, 3, 4]

How can I merge the lists together to make it look something like this:

list3 = [['A', 1], ['B', 2], ['C', 3], ['D', 4]]

Basically I want to make a list inside a list.

I've been trying for loops but nothing seems to be working for me.

Sal W
  • 1

1 Answers1

0

Try this:

list1 = ['A', 'B', 'C', 'D']
list2 = [1, 2, 3, 4]

result = [list(i) for i in zip(list1,list2)]

print(result)

Output:

[['A', 1], ['B', 2], ['C', 3], ['D', 4]]
Chandella07
  • 2,089
  • 14
  • 22