Sum of Digits

Calculate the sum of all digits in a number.

Code

General
sum(int(d) for d in str(abs(num)))

Parameters

Number

Server

More Python Snippets