Display a given vector in a 2D list

1

I have the following problem:

  • I have a 2D vector and I want to display only the first vector ([250, 27.65863337187866, 93.38094023943002, 27.65863337187866]).

  • I've created a code, but it's displaying everything.

  • Below the code:

lista_1 = [[250, 27.65863337187866, 93.38094023943002, 27.65863337187866], [0, 392, 327, 30, 348, 12, 64, 324]]

for i in lista_1:
    print (i)

Where am I going wrong?

Thanks for the help.

    
asked by anonymous 04.03.2017 / 02:16

1 answer

0

I may have misunderstood but if you want to access only the first vector access the index of that vector in the main list:

lista_1 = [[250, 27.65863337187866, 93.38094023943002, 27.65863337187866], [0, 392, 327, 30, 348, 12, 64, 324]]
print(lista[0]) #[250, 27.65863337187866, 93.38094023943002, 27.65863337187866]

In this case, the first is the first internal vector, so it is at index 0

When you do:

for i in lista_1:
    print (i)

You are scrolling through the entire list by printing each internal vector at each loop loop, print all.

    
04.03.2017 / 02:19