I ask for help, it is impossible to loop through only the first element (dictionaries) of each tuple. The maximum that happened:
data = [ ({'a':a, 'b':b},[a,b]), ({'a':a, 'b':b},[a,b]), ({'a':a, 'b':b},[a,b]) ] a = lambda a: aa for tuples in data: for dict_and_list in tuples: print('\n', dict_and_list) I get the output: {'a': a, 'b': b} [a, b], etc. It is necessary to go through the dictionary and group it by a certain value. The problem is that I cannot figure out how to make the next cycle run only on the first element of the tuples (dictionaries) in order to further group it.
Got to this option, but now it is impossible to group and display together the elements of the dictionary and the elements of the list.
a = lambda a: aa tags = [tuples[0] for tuples in data] name_and_path = [tuples[1] for tuples in data] group_by = groupby(tags, a) for key, info in group_by: print("\n", key) for tag in info: print('{0}'.format(tag.a))