Remove comma from tuples in python.
Gary Herron
gary.herron at islandtraining.com
Fri Feb 21 03:27:24 EST 2014
On 02/20/2014 10:49 PM, Jaydeep Patil wrote:
> 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))
>
>
>
> please suggest me solution.
>
>
>
> Regards
> jay
There are no extra *commas* there. Perhaps you mean extra
*parentheses*? When Python parses that line, the extra parentheses are
used to control the evaluation (unnecessarily in this case, as it turns
out), and won't be in the final result.
>>> 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))
>>> 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)
A bit of notation, because I''m not sure we are communicating well here:
A tuple is a Python data structure. It has no commas or
parentheses. The *printing* of a Python tuple uses both for it's
appearance on the output, but the tuple itself has no such thing.
Gary Herron
More information about the Python-list
mailing list