Skip to content

Commit bf3748c

Browse files
committed
add the docs for the sum_of_digits
1 parent 63b33fc commit bf3748c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sum_of_digits_of_a_number.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def sum_of_digits(n: int) -> int:
4949
Compute the sum of the digits of an integer.
5050
5151
Args:
52-
n: A non-negative integer.
52+
n:Non - negative integer
53+
If the integer is negative , it is converted to postive interger and assigned to same number
5354
5455
Returns:
5556
Sum of digits of the number.
@@ -60,6 +61,7 @@ def sum_of_digits(n: int) -> int:
6061
>>> sum_of_digits(405)
6162
9
6263
"""
64+
n=abs(n)
6365
total = 0
6466
while n > 0:
6567
# Add last digit and remove it from n

0 commit comments

Comments
 (0)