Skip to content

Commit 7749db8

Browse files
authored
Create number_of_digits.py
A python program to find the number of digits in a number.
1 parent ba8b156 commit 7749db8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

maths/number_of_digits.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def num_digits(n):
2+
digits=0;
3+
while(n>0):
4+
n=n//10;
5+
digits=digits+1
6+
return digits
7+
8+
num=12345
9+
print("Number of digits in " + str(num) + " is : " + str(num_digits(num)))

0 commit comments

Comments
 (0)