Python novice here.
I have the following nested tuple containing values, sides and context:
<code>my_tuple = [(121, 131, 174, 188, 228, 242, 282),
('Left', 'Right', 'Right', 'Left', 'Left', 'Right', 'Right'),
('Foot Strike',
'Foot Off',
'Foot Strike',
'Foot Off',
'Foot Strike',
'Foot Off',
'Foot Strike')]
</code>
<code>my_tuple = [(121, 131, 174, 188, 228, 242, 282),
('Left', 'Right', 'Right', 'Left', 'Left', 'Right', 'Right'),
('Foot Strike',
'Foot Off',
'Foot Strike',
'Foot Off',
'Foot Strike',
'Foot Off',
'Foot Strike')]
</code>
my_tuple = [(121, 131, 174, 188, 228, 242, 282),
('Left', 'Right', 'Right', 'Left', 'Left', 'Right', 'Right'),
('Foot Strike',
'Foot Off',
'Foot Strike',
'Foot Off',
'Foot Strike',
'Foot Off',
'Foot Strike')]
I would like to extract the values which agree with ‘Right’ AND ‘Foot Strike’ (i.e. val = 174 & 282).
I know I could extract the first indices of all subtuples by using
<code>first = [lis[0] for lis in my_tuple]
</code>
<code>first = [lis[0] for lis in my_tuple]
</code>
first = [lis[0] for lis in my_tuple]
and subsequently select the first vaule of that tuple, but I am failing to correctly set conditional values to go with this selection.
Thank your for helping out the newbie!
New contributor
IVM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.