Accessing items in nested tuples

Tim Chase python.list at tim.thechases.com
Tue Apr 21 16:15:11 EDT 2009


> IDLE 1.2.1
>>>> data=(("aa", ("bb", "cc", "dd")), ("ee", ("ff", "gg", "hh")), ("ii", ("jj", "kk", "ll")))
>>>> print data[0]
> ('aa', ('bb', 'cc', 'dd'))
>>>> print data[1]
> ('ee', ('ff', 'gg', 'hh'))
>>>> etc...
> 
> 
> I would like to be able to access the dataitem "aa" or "bb", "cc",
> "dd" individualy.

You're sooooo close:

   >>> print data[0][0]
   'aa'
   >>> print data[1][0]
   'ee'

-tkc





More information about the Python-list mailing list