OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Combine multiple conditions for finding elements in nested tuple

  • Thread starter Thread starter IVM
  • Start date Start date
I

IVM

Guest
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')]

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]

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!
<p>Python novice here.</p>
<p>I have the following nested tuple containing values, sides and context:</p>
<pre><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></pre>
<p>I would like to extract the values which agree with 'Right' AND 'Foot Strike' (i.e. val = 174 & 282).</p>
<p>I know I could extract the first indices of all subtuples by using</p>
<pre><code>first = [lis[0] for lis in my_tuple]
</code></pre>
<p>and subsequently select the first vaule of that tuple, but I am failing to correctly set conditional values to go with this selection.</p>
<p>Thank your for helping out the newbie!</p>
 

Latest posts

Top