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
On 01/10/2017 10:31 PM, 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
Almost:
# /usr/bin/env python
Python 2.7.3 (default, Sep 22 2012, 02:37:18)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" f
On 11/01/17 06:31, 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
You can write a function(*) to flatten the data structure,
but you need to be careful and think through how you
expect it to handle strings, say... or
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
Thanks in advance
Ram.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor