Python sum, why not strings? [closed]
问题 Closed . This question is opinion-based. It is not currently accepting answers. Closed last year . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Python has a built in function sum , which is effectively equivalent to: def sum2(iterable, start=0): return start + reduce(operator.add, iterable) for all types of parameters except strings. It works for numbers and lists