Skip to content

Commit a20af76

Browse files
Merge pull request #3064 from s2kumar2007/sum
add the doc in sum_of_digits
2 parents 63b33fc + 6c03320 commit a20af76

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ Feel free to explore the scripts and use them for your learning and automation n
5858
43. [smart_file_organizer.py](https://github.com/sangampaudel530/Python2.0/blob/main/smart_file_organizer.py) - Organizes files in a directory into categorized subfolders based on file type (Images, Documents, Videos, Audios, Archives, Scripts, Others). You can run it once or automatically at set intervals using the `--path` and `--interval` options.
5959
<hr>
6060

61-
_**Note**: The content in this repository belongs to the respective authors and creators. I'm just providing a formatted README.md for better presentation._
61+
_**Note**: The content in this repository belongs to the respective authors and creators. I'm just providing a formatted README.md for better presentation.

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)