Header Ads Widget

Count number of digit in a number in Python

 Count number of  digit in a number in Python

Given a number , write a program to count number of digits in a number . 

Sample input

78563

Sample output

5

  Count number of  digit in a number in Python

The objective of the code is to find the number of digits in a given number in Pyhton .

Code(Python):-

num=int(input("Enter a number\n"))
count=0
while(num!=0):
count+=1
num//=10
print("Number of digits is ",count)

Output:-

Enter a number
78536
Number of digits is 5

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-