Reputation: 103
I have two vectors of numbers:
vector_a = (5,10,15,20,25)
vector_b = (6,11,16,21,26)
And I want to have a list that gathers the information in this way:
[[5,6], [10,11], [15,16], [20,21], [25,26]]
Can anyone give me a clue of how to achieve this?
Upvotes: 0
Views: 165
Reputation: 9711
Wrapping the zip
function in the list
function will do just that:
list(zip(list_a, list_b))
Upvotes: 0
Reputation: 5889
You could use zip.
new = [list(x) for x in zip(vector_a,vector_b)]
output
[[5, 6], [10, 11], [15, 16], [20, 21], [25, 26]]
Upvotes: 1