Remove comma from tuples in python.

Bernd Nawothnig Bernd.Nawothnig at t-online.de
Fri Feb 21 02:20:31 EST 2014


On 2014-02-21, Mircescu Andrei wrote:
> vineri, 21 februarie 2014, 08:49:01 UTC+2, Jaydeep Patil a scris:
>> I am getting below tuple from excel.
>> 
>> How should i remove extra commas in each tuple to make it easy for operations.
>> 
>> 
>> 
>> tuples is:
>> 
>> seriesxlist1 = ((0.0), (0.01), (0.02), (0.03), (0.04), (0.05), (0.06), (0.07), (0.08), (0.09), (0.1), (0.11))
>
> i think you have a tuple of tuples there. a tuple of 12 tuples.

No it isn't:

#v+
>>> a = ((0.0), (0.01), (0.02), (0.03), (0.04), (0.05), (0.06), (0.07), (0.08), (0.09), (0.1), (0.11))
>>> a
(0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11)
#v-

The comma makes a tuple, not the parenthesis alone:


#v+
>>> a = ((0.0,), (0.01,), (0.02,), (0.03,), (0.04,), (0.05,), (0.06,), (0.07,), (0.08,), (0.09,), (0.1,), (0.11,))
>>> a
((0.0,), (0.01,), (0.02,), (0.03,), (0.04,), (0.05,), (0.06,), (0.07,), (0.08,), (0.09,), (0.1,), (0.11,))
>>> 
#v-




Bernd

-- 
no time toulouse



More information about the Python-list mailing list