65. Python Program to find the number of Digits of a given number.
How does this program work?
- This program is used to find the number of digits of a given number using Python.
- The integer entered by the user is stored in variable n.
- Here we are using while loop and this loop will be iterated upto n not equal to zero, once n will be zero the loop is terminated.
Here is the code
n = int(input("Enter a number: "))
a = 0
count =0
while n > 0:
b = n % 10
a += b
count += 1
n//=10 #(n = int(n/10))
print("Number of digits in a number are: ",count)