blob: 6ef83403ed0bb45cfae288e890f2b4f940ec6bc7 (
plain)
1
2
3
4
5
6
|
from itertools import groupby
def group_element(test_list):
res = dict()
for key, val in groupby(sorted(test_list, key = lambda ele: ele[1]), key = lambda ele: ele[1]):
res[key] = [ele[0] for ele in val]
return (res)
|