0

I want to combine multiple lists into 1 list without using zip() since zip() will convert expected_list to a list of tuples. I want expected_result is a list of lists.

list1 = [ "a" 
          "b" 
          "c" ]
list2 = [ "e" 
          "f"
          "g" ]

expected_list = [ [ "a", "e" ]
                  [ "b" ,"f" ]  
                  [ "c" ,"g" ] ]

any solution for this ?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
mht
  • 133
  • 1
  • 2
  • 9

1 Answers1

2

Try this:

[[i, j] for i, j in zip(list1, list2)]

Or as ekhumoro wrote below:

list(map(lambda *x: list(x), a, b)).
ncopiy
  • 1,515
  • 14
  • 30