<br><br><div class="gmail_quote">On Tue, Aug 24, 2010 at 9:53 PM, Nitin Das <span dir="ltr">&lt;<a href="mailto:nitin.162@gmail.com">nitin.162@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

alternatively you can use the lambda , reduce function for summing up all the numbers in a list for e.g:-<div><br></div><div>lis = [1,2,3,4,5]</div><div><br></div><div>p = reduce(lambda x,y : x+y, lis)</div><div><br></div>


<div>p will have the value = 15.</div></blockquote><div><br></div><div>Another approach,</div><div><br></div><div>&gt;&gt;&gt; lis = [1,2,3,4,5]</div><div>&gt;&gt;&gt; reduce(operator.add, lis)</div><div>15</div><div> </div>

<div>However use sum() for this, which is the most obvious way to do it.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><br></div><div><br>
</div>
<div>--nitin<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Mon, Aug 23, 2010 at 9:05 PM, aug dawg <span dir="ltr">&lt;<a href="mailto:augdawg09@gmail.com" target="_blank">augdawg09@gmail.com</a>&gt;</span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">Oh okay, sorry about that.<div><br></div><div>Thanks for the help!<div><br>

<div>
<br><br><div class="gmail_quote">On Mon, Aug 23, 2010 at 11:33 AM, Sander Sweers <span dir="ltr">&lt;<a href="mailto:sander.sweers@gmail.com" target="_blank">sander.sweers@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>On 23 August 2010 17:24, aug dawg &lt;<a href="mailto:augdawg09@gmail.com" target="_blank">augdawg09@gmail.com</a>&gt; wrote:<br>
&gt; So it&#39;s sum(list_name) ?<br>
<br>
</div>Correct, but it is not limited to lists. Any itterable with<br>
ints/floats will do, for example a tuple is also accepted.<br>
<br>
Greets<br>
<font color="#888888">Sander<br>
</font><br>
PS: Please use reply to all so others on this list may benefit from<br>
the questions/answers ;-)<br>
</blockquote></div><br></div></div></div>
<br></div></div><div class="im">_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></div></blockquote></div><br></div>
<br>_______________________________________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>~l0nwlf<br>