Count number of Digits in a number - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Friday, June 19, 2020

Count number of Digits in a number



python-mini

Question

To Count the number of digits in a number.

Sample TestCaseExpected Output

Enter a number : 1234The number of digits is 4

Answer


n=int(input("Enter a number  : "))
count=0
while(n>0):
    count+=1
    n=n//10
print("The number of digits is :",count)    

No comments:

Post a Comment