0

There is a 3 dimension list.

a = [[[1, 2], [2, 3], [3, 4]], [[4, 5], [5, 6], [6, 7]], [[7, 8], [8, 9], [9, 10]], [[10, 11], [11, 12], [12, 13]]]

so,

a[0][0][1] is 2

a[0][1][1] is 3

a[0][2][1] is 4

a[1][0][1] is 5

a[1][1][1] is 6

a[1][2][1] is 7

...

If I want to remove of particular element, such as a[:][:][1]

I haved tried that

a.pop([0][0][1])

Tnen, Traceback (most recent call last): File "", line 1, in

TypeError: 'int' object is not subscriptable
Saurabh Mistry
  • 12,833
  • 5
  • 50
  • 71

1 Answers1

0

Try:

a[0][0].pop(1)

Given the list a in your question this would pop the number 2 from the list and a would look like this:

>>>a = [[[1], [2, 3], [3, 4]], [[4, 5], [5, 6], [6, 7]], [[7, 8], [8, 9], [9, 10]], [[10, 11], [11, 12], [12, 13]]]

See the note in the Python list.pop documentation.

It says:

The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference

Zoe
  • 27,060
  • 21
  • 118
  • 148
noel
  • 2,257
  • 3
  • 24
  • 39