-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
  • 9,972
  • 7
  • 57
  • 66
lucascavalcante
  • 1,166
  • 1
  • 10
  • 28
  • 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
  • 9,972
  • 7
  • 57
  • 66
SuperStew
  • 2,650
  • 2
  • 13
  • 25