Python program to find number of digits in a number

Hello everyone, welcome back to programminginpython.com! Here in this post I will show you how to find the number of digits in a number. A pretty simple logic.

You can watch this video on Youtube here

Program on Github

Find number of digits in a number – Code Visualization

Task

To find the number of digits in a given number.

Approach

  • Read the number whose digits to be counted.
  • Use a while loop to get each digit of the number using a modulus // operator
  • Increment after a digit is obtained.
  • Continue until the value of the number is 0
  • Print the total count(number of digits) of the number.

Program on Github

Program

Program on Github

Output

Number of digits in number - programminginpython.com
Number of digits in number – programminginpython.com
Number of digits in number - programminginpython.com
Number of digits in number – programminginpython.com

 

You can watch this video on Youtube here

 

Leave a Reply