You can download this code by clicking the button below.
This code is now available for download.
This function calculates the sum of all digits of an integer.
Technology Stack : Built-in functions str(), int(), sum(), for loop, if statement
Code Type : Function
Code Difficulty :
def sum_digits(n):
return sum(int(digit) for digit in str(n) if digit.isdigit())