1

How can one get the second value of every array inside the outside array? I have the following data data = {{10, 20}, {30, 40}, {50, 60}};

I want to extract 20, 40 and 60 from it. I have tried the following:

data = {{10, 20}, {30, 40}, {50, 60}};

data2 = data[[{1, 2, 3}]][[2]]
{30, 40}

But that doesn't seem to work.

Yves Klett
  • 15,383
  • 5
  • 57
  • 124
Frank44
  • 11
  • 1
  • 1
    @Kuba I think this one is much closer to RTFM than to that question. May be we want to keep this one though, this is a common question. – Leonid Shifrin Mar 05 '14 at 12:34
  • @LeonidShifrin So you say "simple mistake" :)? I think you're right, it is 5th example for Part documentation so it is a good reason to close. Marking it a duplicate will not help I think, It will be hard to find this question in the future, with this title - impossible. – Kuba Mar 05 '14 at 12:41
  • @Kuba Yes, I think it's right. – Leonid Shifrin Mar 05 '14 at 12:42
  • 1
    @Kuba perhaps with a different title it might serve as an entry point, even if it is RTFM. – Yves Klett Mar 05 '14 at 12:58
  • @YvesKlett I've retracted my "duplicate" vote so now it's up to community :) – Kuba Mar 05 '14 at 13:04

1 Answers1

2

Many ways to achieve that. Any of the following (and many more)

data[[All,2]] 
Last/@data 
Transpose[data][[2]]

should do the trick.

Yves Klett
  • 15,383
  • 5
  • 57
  • 124