Search the difference: Why this function defenition does'nt work?

husam h.jehadalwan at
Sun Dec 23 10:08:49 CET 2001

Luke wrote:

> If you use a list index [0] that returns a single element of the type 
> that that element is (which is what you want in this case).  But when 
> you use the colon for slice notation, you are asking python to return a 
> tuple of all the elements up to the zeroth element, which is no 
> elements--an empty tuple.  Then you are trying to add a number to a 
> tuple which is undefined.

But when I adjust the code to this:


it still does not work, despite the fact that sum is not an undefined 
object, right?

More information about the Python-list mailing list