Very nice, that works!  Thanks so much, Chris!<br><br><div class="gmail_quote">On Wed, Oct 22, 2008 at 1:06 PM, Chris Rebert <span dir="ltr"><<a href="mailto:clp@rebertia.com">clp@rebertia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Wed, Oct 22, 2008 at 12:59 PM, Henry Chang <<a href="mailto:goldspin@gmail.com">goldspin@gmail.com</a>> wrote:<br>
> This seems like a simple problem, but I can't find a simple solution.<br>
><br>
> Suppose I have two lists of integers.<br>
><br>
> List A = [A1, A2, A3]<br>
> List B = [B1, B2, B3]<br>
><br>
> I just simply want a new list, such as:<br>
><br>
> List C = [C1, C2, C3]<br>
><br>
> where:<br>
><br>
> C1 = A1 + B1<br>
> C2 = A2 + B2<br>
> C3 = A3 + B3<br>
><br>
> Is there a simple function to do this?<br>
<br>
</div></div>A one-liner in fact:<br>
<br>
summed = [sum(pair) for pair in zip(listA, listB)]<br>
<br>
Explanation: pairs up the elements of listA and listB, sums each pair,<br>
constructs a list of the sums.<br>
<br>
Cheers,<br>
Chris<br>
--<br>
Follow the path of the Iguana...<br>
<a href="http://rebertia.com" target="_blank">http://rebertia.com</a><br>
<br>
><br>
> Thanks so much?<br>
><br>
> --<br>
> <a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
><br>
><br>
</blockquote></div><br>