Write a program to count the number of digits.

Program:

c=0
n=int(input("Enter any no"))
while(n>0):
    d=int(n%10)
    c=c+1 #count number of digits
    n=int(n/10) #convert into integer
print("Number of digits:",c)

    

Comments

Popular Posts