Simple recursive sum function | what's the cause of the weird behaviour?

Russel Walker russ.pobox at gmail.com
Sat Jul 6 14:59:06 CEST 2013


Since I've already wasted a thread I might as well...

Does this serve as an acceptable solution?

def supersum(sequence, start=0):
    result = type(start)()
    for item in sequence:
        try:
            result += supersum(item, start)
        except:
            result += item
    return result



More information about the Python-list mailing list