ramakrishna reddy wrote:

> Hi All,
> 
> Is there any way to convert x = (1, 2, 3, (4, 5)) to x = (1, 2, 3, 4, 5)
> in python 2.7

Is the structure of x always the same? 

Then you can build a new tuple from

>>> x[:-1]  # all items but the last
(1, 2, 3)

and

>>> x[-1]  # the last item
(4, 5)

by concatenating them:

>>> x[:-1] + x[-1]
(1, 2, 3, 4, 5)


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to