Python program to print the frequency of digits present in the given number


Write a program in python to print the frequency of digits present in the given number 

--------------------------------
num=int(input("Enter any Number : "))
print("Digit\tFrequency")
for i in range(0,10):
    count=0;
    temp=num;
    while temp>0:
        digit=temp%10
        if digit==i:
            count=count+1
        temp=temp//10;
    if count>0:
        print(i,"\t",count)
--------------------------------

Output :-

Enter any Number : 461641
Digit Frequency
1 2
4 2
6 2

Post a Comment

0 Comments