You are currently viewing Python Program to check the length of a number.

This is another article in the series of Python practice programs. In this article, we will take input of numbers from uses and will check if a number is a single digit or double-digit. For this, we will use len() function of python. Len function in python returns you the length of the supplied attribute.

In this article, we have used Len function to identify the length of numbers you can also use this to identify the length of the string.

#Program to take input from user and check number is one digit two digit ....

firstNumber =input("enter a number : ")
result = len(firstNumber)
print(result, "digit number")

In the above example, we have taken input as 123 and returned the value 3, which tells that the number we have supplied was a 3 digit number. You can now try this with strings to return the total number of characters in the string.

That’s it Folks on this topic. Let us know your comments on this article in the comment box below. Kindly like our facebook page, follows us on twitter and subscribe to our YouTube channel for latest updates.

Leave a Reply