-7

Let the array a be:

a = [[1, 2], [1, 2, 3], [1, 2, 3, 4]]

How can one obtain the following list?

b = [[2], [2, 3], [2, 3, 4]]
Georgy
  • 12,464
  • 7
  • 65
  • 73
cavalcantelucas
  • 1,362
  • 3
  • 12
  • 34
  • 4
    By creating a new list where each entry consists of one entry of the original list without the first element. – mkrieger1 Jan 31 '18 at 16:52
  • 1
    Related: [How do I delete the Nth list item from a list of lists (column delete)?](https://stackoverflow.com/q/13244466/7851470) – Georgy Jan 08 '20 at 14:06

1 Answers1

4

Well, for this example, you could use list comprehension with slicing.

a = [[1, 2], [1, 2, 3], [1, 2, 3, 4]]
b = [x[1:] for x in a]
Georgy
  • 12,464
  • 7
  • 65
  • 73
SuperStew
  • 2,857
  • 2
  • 15
  • 27