Connecting Tech Pros Worldwide Forums | Help | Site Map

extracting data from tuples

Newbie
 
Join Date: Oct 2007
Posts: 28
#1: Aug 17 '09
I have a tuple that prints from a program somewhat like this:
tuple1(0, [ [1, 2, 3, 4,] ])
when i do a len(tuple1) command it says the length of the tuple is 2 which i guess it is looking at it because its treating the 1 2 3 4 as one entry.

however i am trying to extract the 1 2 3 and 4 from it. i have tried various combinations of multidimension array commands mainly things like print tuple1[1][0] etc.. but cant for the life of me extract the 1 2 3 and 4 individually.

Can someone help me with this? it looks like it would be simple to do but i have googled it and cant find a solution.

Thanks
bvdet's Avatar
Moderator
 
Join Date: Oct 2006
Location: Nashville, TN
Posts: 1,563
#2: Aug 17 '09

re: extracting data from tuples


Tuple index [1] is a list of lists with one element.

Expand|Select|Wrap|Line Numbers
  1. >>> s = (0, [ [1, 2, 3, 4,] ])
  2. >>> s[1][0][0]
  3. 1
  4. >>> 
Reply