[Python] How to slice a list of lists

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    I have an input stream as follows:

    data = [[1,234],[2,432],[3,443]]


    How can I get the second element of every list? I can get the second value of a single entry by data[0][1], or every list in a range with both elements using data[0:2], but how to get just the second element from every list? Just looping through the list seems inefficient.

    Continue reading...

Compartilhe esta Página