-1
a = [1, 2, 3]
b = [4, 5, 6]

res = next(zip(a, b))
print(res)

Output:

(1,4)

how to get every pair in aa a separate list?

Expected Output:

[1,4]
[2,5]
[3,6]
Aplet123
  • 33,825
  • 1
  • 29
  • 55
Stark
  • 197
  • 1
  • 7

1 Answers1

0

you can zip the items in a list and unpack them in a list comp.

new_list = [[x,y] for x,y in  zip(a,b)]

print(new_list)
[[1, 4], [2, 5], [3, 6]]

the issue with your solution is your first turning your lists into an iterator (correct) but you are only calling the first value with next

Umar.H
  • 22,559
  • 7
  • 39
  • 74