In a Python program, I have a list of lists of tuples:
x = [[(frozenset({(5, 'Y')}), 5, 'Y')],
[(frozenset({(9, 'Y'), (2, 'Y'), (7, 'N'), (3, 'Y')}), 2, 'Y'),
(frozenset({(4, 'Y'), (0, 'Y'), (8, 'N'), (1, 'Y')}), 4, 'Y'),
(frozenset({(9, 'Y'), (2, 'Y'), (7, 'N'), (3, 'Y')}), 3, 'Y')],
[(frozenset({(9, 'Y'), (2, 'Y'), (7, 'N'), (3, 'Y')}), 7, 'N'),
(frozenset({(4, 'Y'), (0, 'Y'), (8, 'N'), (1, 'Y')}), 8, 'N')]]
It has 3 main components:
x[0] = [[(frozenset({(5, 'Y')}), 5, 'Y')]
x[1] = [(frozenset({(9, 'Y'), (2, 'Y'), (7, 'N'), (3, 'Y')}), 2, 'Y'), (frozenset({(4, 'Y'), (0, 'Y'), (8, 'N'), (1, 'Y')}), 4, 'Y'), (frozenset({(9, 'Y'), (2, 'Y'), (7, 'N'), (3, 'Y')}), 3, 'Y')];
x[2] = [(frozenset({(9, 'Y'), (2, 'Y'), (7, 'N'), (3, 'Y')}), 7, 'N'), (frozenset({(4, 'Y'), (0, 'Y'), (8, 'N'), (1, 'Y')}), 8, 'N')]].
They have different sizes. I would like to check if all the last components of the 3 lists meet a specific condition: 'Y' if all of them are 'Y'; 'N' if all of them are 'N'; or 'U' if there exists some 'Y' and some 'N' in each component. The result should in this example be something like: ['Y', 'Y', 'N'].
How can I solve this problem?