Skip to content
Advertisement

Python: Sum string lengths

Is there a more idiomatic way to sum string lengths in Python than by using a loop?

JavaScript

I tried sum(), but it only works for integers:

JavaScript

Advertisement

Answer

I know this is an old question, but I can’t help noting that the Python error message tells you how to do this:

JavaScript

So:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement