Thanks Bruno. I just missed it. I got it back and thanks Blockhead for
giving me new angle to look into the problem.
Best Regards,
Subhabrata.
Nothing personal, but it's Blockheads (plural) AND you missed the OI OI.
What is the problem with modern day education? :)
--
http://mail.python.org
On Saturday 26 March 2011 02:27:12 Jason Swails wrote:
> I'm guessing you have something like
>
> list1=['1.0', '2.3', '4.4', '5.5', ...], right?
>
> You can do this:
>
> for i in range(len(list1)):
> list1[i] = float(list1[i])
Better,
list1 = [float(v) for v in list1]
One statement only -
On Fri, 25 Mar 2011 08:19:24 -0700, joy99 wrote:
> Dear Group,
>
> I got a question which might be possible but I am not getting how to do
> it.
>
> If I have a list, named,
> list1=[1.0,2.3,4.4,5.5]
That looks like a list of floats already. Perhaps you meant:
list1 = ["1.0", "2.3", "4.4",
On Mar 25, 9:19 pm, "bruno.desthuilli...@gmail.com"
wrote:
> On 25 mar, 16:19, joy99 wrote:
>
>
>
> > Dear Group,
>
> > I got a question which might be possible but I am not getting how to
> > do it.
>
> > If I have a list, named,
> > list1=[1.0,2.3,4.4,5.5]
>
> > Now each element in the arra
On 25 mar, 16:19, joy99 wrote:
> Dear Group,
>
> I got a question which might be possible but I am not getting how to
> do it.
>
> If I have a list, named,
> list1=[1.0,2.3,4.4,5.5]
>
> Now each element in the array holds the string property if I want to
> convert them to float, how would I do
On 25/03/2011 15:46, Rafael Durán Castañeda wrote:
But you must be sure that the list only contains objects than can be
converted into float, if not you'll get:
>>> float('something')
Traceback (most recent call last):
File "", line 1, in
float('something')
ValueError: could not conver
But you must be sure that the list only contains objects than can be
converted into float, if not you'll get:
>>> float('something')
Traceback (most recent call last):
File "", line 1, in
float('something')
ValueError: could not convert string to float: something
>>>
2011/3/25 Blockheads O
On 25/03/2011 15:27, Jason Swails wrote:
I'm guessing you have something like
list1=['1.0', '2.3', '4.4', '5.5', ...], right?
You can do this:
for i in range(len(list1)):
list1[i] = float(list1[i])
or
for i, x in enumerate(list1):
list1[i] = float(x)
--
http://mail.python.org/mail
If you want to have it even shorter and you are using Python 2.5 or
greater you can also use:
list1 = [float(list_item) for list_item in list1]
Am 25.03.2011 16:27, schrieb Jason Swails:
I'm guessing you have something like
list1=['1.0', '2.3', '4.4', '5.5', ...], right?
You can do this:
for
I'm guessing you have something like
list1=['1.0', '2.3', '4.4', '5.5', ...], right?
You can do this:
for i in range(len(list1)):
list1[i] = float(list1[i])
There's almost certainly a 1-liner you can use, but this should work.
--Jason
On Fri, Mar 25, 2011 at 8:19 AM, joy99 wrote:
> Dear G
did you try type casting with float ?
On Fri, Mar 25, 2011 at 8:49 PM, joy99 wrote:
> Dear Group,
>
> I got a question which might be possible but I am not getting how to
> do it.
>
> If I have a list, named,
> list1=[1.0,2.3,4.4,5.5]
>
> Now each element in the array holds the string proper
Dear Group,
I got a question which might be possible but I am not getting how to
do it.
If I have a list, named,
list1=[1.0,2.3,4.4,5.5]
Now each element in the array holds the string property if I want to
convert them to float, how would I do it?
Extracting the values with for and appendin
12 matches
Mail list logo