On Fri, 21 Feb 2014 11:13:30 +0200, Jussi Piitulainen wrote: > Gary Herron writes: > >> 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. >> >> There are no extra *commas* there. Perhaps you mean extra > > There were extra commas in a previous thread. > > Jaydeep, Rustom Mody gave you the answer, which you even quoted but > apparently failed to notice. Go back and see. > > That answer was this: > > >>> seriesxlist1 = ((0.0,), (0.01,), (0.02,)) > >>> x2 = [x*x for (x,) in seriesxlist1] > > I tend to omit those parentheses and use just the comma: > > >>> x2 = [x*x for x, in seriesxlist1]
I had not though of using unpacking in this way & would have written x2= [x[0]**2 for x in serisexlist1] I am not sure which is easier to read in this instance (single element tupple) but unpacking would definitely be the way to go if the tupple had multiple values. -- Q: What do they call the alphabet in Arkansas? A: The impossible dream. -- https://mail.python.org/mailman/listinfo/python-list