0

I need to get the values โ€‹โ€‹of the positions of the vectors to be able to visualize them.

I have two vectors

a = [15, 10, 7 , 1, 12, 16]
b = [11, 7, 18, 2, 10, 2]

And I need to get position one of vector a and position one of vector b, then position 2 of vector a and position 2 of vector and so on

I was using a nested form but it does not work as I require it

for x in a:
   for y in b:
      print x,y

this print

15,11
15,7
15,18
15,2
15,10
15,2
10,11
10,7.....

but i need it to print

15, 11
10, 7
7, 18
1, 2
12, 10
16, 2
dot.Py
  • 5,007
  • 5
  • 31
  • 52
Nilson Hernandez
  • 11
  • 1
  • 1
  • 4

1 Answers1

1

Use zip.

>>> a = [15, 10, 7 , 1, 12, 16]
>>> b = [11, 7, 18, 2, 10, 2]
>>> for x,y in zip(a,b):
...     print(x,y)
...
15 11
10 7
7 18
1 2
12 10
16 2
Kevin
  • 74,910
  • 12
  • 133
  • 166