Madhusudan Singh <[EMAIL PROTECTED]> wrote:
...
> >> Say I have two lists of floats. And I wish to generate a list of floats
> >> that is a user defined function of the two lists.
> >
> > result = [sqrt(x**2 + y**2) for x, y in zip(xs, ys)]
>
> Works perfectly. Thanks !
If zip works and map d
Erik Max Francis:
>result = [sqrt(x**2 + y**2) for x, y in zip(xs, ys)]
Another possibility:
from math import hypot
result = [hypot(*xy) for xy in zip(xs, ys)]
Or better:
from math import hypot
result = map(hypot, xs, ys)
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
Erik Max Francis wrote:
> Madhusudan Singh wrote:
>
>> Thanks. Now, a slightly more complicated question.
>>
>> Say I have two lists of floats. And I wish to generate a list of floats
>> that is a user defined function of the two lists.
>
> result = [sqrt(x**2 + y**2) for x, y in zip(xs, ys)]
>
Madhusudan Singh wrote:
> Thanks. Now, a slightly more complicated question.
>
> Say I have two lists of floats. And I wish to generate a list of floats that
> is a user defined function of the two lists.
result = [sqrt(x**2 + y**2) for x, y in zip(xs, ys)]
--
Erik Max Francis && [EMAI
Steve Holden wrote:
> Madhusudan Singh wrote:
>> [EMAIL PROTECTED] wrote:
>>
>>
>>>Madhusudan> Is it possible to convert a very long list of strings to
>>>a Madhusudan> list of floats in a single statement ?
>>>
>>>Madhusudan> I have tried float(x) and float(x[:]) but neither work. I
Madhusudan Singh wrote:
> [EMAIL PROTECTED] wrote:
>
>
>>Madhusudan> Is it possible to convert a very long list of strings to a
>>Madhusudan> list of floats in a single statement ?
>>
>>Madhusudan> I have tried float(x) and float(x[:]) but neither work. I
>>Madhusudan> guess I wou
[EMAIL PROTECTED] wrote:
>
> Madhusudan> Is it possible to convert a very long list of strings to a
> Madhusudan> list of floats in a single statement ?
>
> Madhusudan> I have tried float(x) and float(x[:]) but neither work. I
> Madhusudan> guess I would have to write a loop if t
Madhusudan> Is it possible to convert a very long list of strings to a
Madhusudan> list of floats in a single statement ?
Madhusudan> I have tried float(x) and float(x[:]) but neither work. I
Madhusudan> guess I would have to write a loop if there isn't a way.
Try:
>>> los =
Paul Watson wrote:
> Mohammed Altaj wrote:
>
>> Hi All
>>
>> Thanks for your reply , what i am doing is , i am reading from file ,
>> using readlines() , I would like to check in these lines , if there is
>> line belong to another one or not , if it is , then i would like to
>> delete it
>>
>> ['0
Mohammed Altaj wrote:
> Hi All
>
> Thanks for your reply , what i am doing is , i am reading from file ,
> using readlines() , I would like to check in these lines , if there is
> line belong to another one or not , if it is , then i would like to
> delete it
>
> ['0132442\n', '13\n', '24\n']
>
10 matches
Mail list logo