The example in question begins with array, not with np.array, and array is not defined as an isolated prefix:
data = array([[1,2,3],
[4,5,6],
[7,8,9]])
data[:,[0,2]]
Error:
NameError: name 'array' is not defined
To reproduce the error, you need to drop that array frame (without np. in front, it does not have a definition anyway).
data = [[1,2,3],
[4,5,6],
[7,8,9]]
data[:,[0,2]]
Error:
TypeError: list indices must be integers or slices, not tuple
The user has probably used the inner list of the array for tests but asked the question with a copy from a np.array output. At least in 2021, the question is just plain wrong: it cannot be reproduced. And I doubt that the behaviour was different in 2010 (numpy is the basic package of python).
For completeness, as in the other answers:
data = np.array([[1,2,3],
[4,5,6],
[7,8,9]])
data[:,[0,2]]
Output:
array([[1, 3],
[4, 6],
[7, 9]])
You do not need a nested list to reproduce this. Slicing a one-dimensional list by two dimensions like with
[1,2][:, 0]
throws the same TypeError: list indices must be integers or slices, not tuple.
NameError: name 'array' is not defined. At least "today", the question is plain wrong, and I doubt it was different in 2010.