extracting data from tuples

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fahadqureshi
    New Member
    • Oct 2007
    • 28

    extracting data from tuples

    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
    Recognized Expert Specialist
    • Oct 2006
    • 2851

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

    Code:
    >>> s = (0, [ [1, 2, 3, 4,] ])
    >>> s[1][0][0]
    1
    >>>

    Comment

    Working...