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]
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