tuples within tuples
Larry Bates
larry.bates at websafe.com
Fri Oct 26 08:34:45 EDT 2007
korovev76 at gmail.com wrote:
> Hello everybody.
>
> I'm wondering how to iterate over a tuple like this
> [A,B,C,D]
> while saving A and C in a list.
>
> My problem is that C sometimes is a tuple of the same structure
> itself...
>
>
> thanks!
> korovev
>
First of all [A,B,C,D] is a list not a tuple. (A,B,C,D) is a tuple.
Without a better example or explanation of what you are trying to do it is
difficult, but I'll give it a try:
myTuple=(A,B,C,D)
for n, item enumerate(myTuple):
if n in (0,2):
myList.append(item)
-Larry
More information about the Python-list
mailing list