# Don't understand the number of levels of "Flatten" [duplicate]

I have a data

data={{{-(1/2), -(3/2)}, {1/2, -(1/2)}, {3/2, 1/
2}}, {{-(3/2), -(5/2)}, {-(1/2), -(3/2)}, {1/2, -(1/2)}, {3/2, 1/
2}, {5/2, 3/2}}}

I want to change this data to this

Inorder solve this ploblem I can use

TreeForm@data

get this

By looking at the data, I found that the second part lsit should be deleted

I want to get rid of all the parentheses here

I tried a lot of things to no avail, so I finally asked "chatgpt"

Flatten[data, {{1}, {2, 3}}]

The problem is solved, but I don't understand how to use the "layer number" in Flatten, I'm confused

• Flatten left layer (aka level) 1 alone and flattened layers 2 and 3. (You have layer 3 outlined in the red box. Everything below it was put into layer two, divided according to layer 2.) Commented Mar 27, 2023 at 13:49
• @MichaelE2 As you can see, the list of the third layer connects the data, why not flatten the third layer?, I don't understand Commented Mar 27, 2023 at 13:51
• In my view, the third layer was flattened. What do you mean - that is, what did you expect the output to be? Commented Mar 27, 2023 at 13:52
• @MichaelE2 How to understant levels of "Flatten" function? Commented Mar 27, 2023 at 13:53
• The flatten code says leave level 1 alone and flatten each item in level with its contents down to level 3. The hard one to describe is when the levels are transposed, such as in Flatten[data, {{1, 3}, {2}}], which might be the code you desire. Commented Mar 27, 2023 at 13:58