4

I am getting this: {{{{{{1, 1}}, {2, 4}}, {3, 9}}, {4, 16}}, {5, 25}}

I want it like this: {{1, 1}, {2, 4}, {3, 9}, {4, 16}, {5, 25}} so that I can use this as coordinate points in ListPlot to make a plot.

I tried using Flatten (it removes all the inner brackets so that it stops being a coordinate) , First etc but nothing worked. Please help

Lost
  • 226
  • 1
  • 7
  • Thank you. As of now, using cvgmt's method works perfectly fine. I will check the link out, nonetheless. – Lost Sep 23 '20 at 08:59
  • 1
    A simple method is to Flatten as you suggested but then to Partition into sublists of 2. This should work: Partition[Flatten[list],2] – Hugh Sep 23 '20 at 10:36

1 Answers1

7
list= {{{{{{1, 1}}, {2, 4}}, {3, 9}}, {4, 16}}, {5, 25}};
Level[list, {-2}]

We can using TreeForm to understand the method.

list= {{{{{{1, 1}}, {2, 4}}, {3, 9}}, {4, 16}}, {5, 25}};
TreeForm[list]

enter image description here

cvgmt
  • 72,231
  • 4
  • 75
  • 133
  • Just a note that while this code solves this particular problem, it is not a general solution, since it only works for atomic list elements (numbers in this case). – Leonid Shifrin Sep 23 '20 at 07:47
  • @LeonidShifrin Thank you,I will go to learn the new method which the link provide. – cvgmt Sep 23 '20 at 08:16