Converting a Tuples List into a nested List using Python -


I want to convert a tuples list to nested lists via python.

  [(1, 5), (5, 4) How can I do that?  

I have a sorted list of Tuples (sorted by second value), (13, 3), (4, 3), (3, 2), (14, 1), (12, 1) ), (10, 1), (9, 1), (8, 1), (7, 1), (6, 1), (2, 1)]

I want it like this (the second value is kept in mind and nested in the lists):

  [[1], [5], [13, 4], [3] , [14, 12, 10, 9, 8, 7, 6, 2]]  

I use the other thread here with the map I've seen it, but I do not fully understand it. Can someone provide insight into the 'right' dragon way to do this?

  group group importing from imported item from operator lst = [(1, 5 ), (5, 4), (13, 3), (4, 3), (3, 2), (14, 1), (12, 1), (10, 1), (9, 1) (8, 1), (7, 1), (6, 1), (2, 1)] result = [[x for x, group y] group, by group (lct, main = mass index (1) )  

By group (lst, key = itemgetter (1)) Constants a group of elements continuously LST within which All elements have the same 1 (zero-count) item [group in x, x, y] each Holds 0th item of each element of the group.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -