Well, it's really just joining the lists.
Try the following code:
a = ['Laranja', 'Maçã', 'Uva', 'Melancia', 'Limão']
b = [40, 50, 2, 45, 56, 12, 21, 12, 12, 12, 12, 12, 12, 12]
x = []
for i in range(len(a) or len(b)):
x.append([a[i],b[i]])
print(x)
Documentation:
- I have created the a vector with some extra strings for testing.
- I created the b vector with more values than the other list to only merge and not mess up if it has more values.
- I created the empty x vector to assign a dynamic value
- I made a loop of i starting from 0 going to the joint size of the two vectors using logical function or
- With .append I am able to add a 'cell' in the vector where, I assign to a position [valueA, valueB] and so on by creating an array of arrays
- Print x to see the result
Result:
[['Laranja', 40], ['Maçã', 50], ['Uva', 2], ['Melancia', 45], ['Limão', 56]]