mysum([ ] mysum((' '' '' '' ')'spammysum(['spam''ham''eggs']'spamhameggsmysum([]fails in last but various types now work run these on your own for more insight if you study these three variantsyou'll find thatthe latter two also work on single string argument ( mysum('spam'))because strings are sequences of one-character strings the third variant works on arbitrary iterablesincluding open input files (mysum(open(name)))but the others do not because they index illustrates extended sequence assignment on filesthe function header def mysum(first*rest)although similar to the third variantwouldn' work at allbecause it expects individual argumentsnot single iterable keep in mind that recursion can be directas in the examples so faror indirectas in the following ( function that calls another functionwhich calls back to its callerthe net effect is the samethough there are two function calls at each level instead of onedef mysum( )if not lreturn return nonempty(lcall function that calls me def nonempty( )return [ mysum( [ :]indirectly recursive mysum([ ] loop statements versus recursion though recursion works for summing in the prior sectionsexamplesit' probably overkill in this context in factrecursion is not used nearly as often in python as in more esoteric languages like prolog or lispbecause python emphasizes simpler procedural statements like loopswhich are usually more natural the whilefor exampleoften makes things bit more concreteand it doesn' require that function be defined to allow recursive callsl [ sum while lsum + [ [ :recursive functions