Count Number of Digits in a Number in Python Using inbuilt Method

(Last Updated On: 30/03/2023)

Python Program to Count the Number of Digits Present In a Number Using inbuilt Method

# Count the Number of Digits Present In a Number Using inbuilt methods in python

num = 123456

# first convert the integer value into string by using str(). Then, we find the length of the string using len().
print(len(str(num)))

Output:

6

Leave a Reply

Your email address will not be published. Required fields are marked *