;

Python Program to Count Number of Digits in a Number


Tutorialsrack 25/04/2020 Python

In this Python program, we will learn how to count the number of digits in a number.

Here is the source code of the program to count the number of digits in a number.

Python Program to Count Number of Digits in a Number
# Python Program to Count Number of Digits in a Number

# To Take the Input from theUser
Number = int(input("Enter any Number: "))
Count = 0
while(Number > 0):
    Number = Number // 10
    Count = Count + 1

print("Number of Digits in a Given Number = %d" %Count)
Output

Enter any Number: 52456

Number of Digits in a Given Number = 5

 

Enter any Number: 524685

Number of Digits in a Given Number = 6


Related Posts



Comments

Recent Posts
Tags