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
- Input a number.
- Run while loop with condition num>0.
- Increment count with 1 and update num by removing last digit i.e num=num//10.
- End loop and output count.
num = int(input("Enter a numer \n"))
count = 0
#counting number of digits in 'num'
num = num//10;
print("Number of Digits: %d"%count)
If you have any suggestion or doubt then comment below.