Learn about **Count Number of Digits in a Number using Math Module** in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.

#### Count Number of Digits in a Number using Math Module

You can use simple logarithms in the math module to determine the length of the number. In the below program we are importing the math module and performing some basic operations.

**Source code :**

```
# Python program to count number of digits in a number
# importing math module
import math
# input
num = int(input('Enter any number: '))
# count number of digits
count = math.floor(math.log10(num)+1)
# printing number of digits
print('Number of digits:', count)
```

**Output:**

Enter any number: 1234

Number of digits: 4

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

**Similar Code :** Length of integer in Python