The problem is simple, we need to write a program in python to count the number of digits in a given number.

Steps to Count Number of Digits in Python

  1. Input a number.
  2. Run while loop with condition num>0.
  3. Increment count with 1 and update num by removing last digit i.e num=num//10.
  4. End loop and output count.

Python Program

num = int(input("Enter a numer \n"))
count = 0

#counting number of digits in 'num'
while num>0:
    count +=1
    num = num//10;
    
print("Number of Digits: %d"%count)

Output

Count number of digits in python

If you have any suggestion or doubt then comment below.