<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
If you want to have it even shorter and you are using Python 2.5 or
greater you can also use:<br>
list1 = [float(list_item) for list_item in list1]<br>
<br>
Am 25.03.2011 16:27, schrieb Jason Swails:
<blockquote
cite="mid:AANLkTikOHHQeGYCRa-rutbJFNN_42ae7WGUHQF+AZmw7@mail.gmail.com"
type="cite"><font color="#000000">I'm guessing you have something
like<br>
<br>
list1=['1.0', '2.3', '4.4', '5.5', ...], right?<br>
<br>
You can do this:<br>
<br>
for i in range(len(list1)):<br>
list1[i] = float(list1[i])<br>
<br>
There's almost certainly a 1-liner you can use, but this should
work.<br>
<br>
--Jason<br>
</font><br>
<div class="gmail_quote">On Fri, Mar 25, 2011 at 8:19 AM, joy99 <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:subhakolkata1234@gmail.com">subhakolkata1234@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">Dear Group,<br>
<br>
I got a question which might be possible but I am not getting
how to<br>
do it.<br>
<br>
If I have a list, named,<br>
list1=[1.0,2.3,4.4,5.5....]<br>
<br>
Now each element in the array holds the string property if I
want to<br>
convert them to float, how would I do it?<br>
<br>
Extracting the values with for and appending to a blank list
it would<br>
not solve the problem. If appended to a blank list, it would
not<br>
change the property.<br>
<br>
If any one of the learned members can kindly suggest any
solution?<br>
<br>
Thanks in advance.<br>
Best Regards,<br>
Subhabrata.<br>
<font color="#888888">--<br>
<a moz-do-not-send="true"
href="http://mail.python.org/mailman/listinfo/python-list"
target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote>
</div>
</blockquote>
<br>
</body>
</html>