Search

To write a program to count a number of occurrence of a character

by 10:36:00 0 comments
SOURCE CODE:


a=raw_input()
c=0
l=[]
for i in a:
    l.append(i)
l.sort()
for i in range(len(a)):
    if l[i]==l[i+1]:
        c+=1
    else:
        print l[i],"Occurs",c+1,"times"
        c=0


Input:

gokulkannan

Output:

a Occurs 2 times 
g Occurs 1 times 
k Occurs 2 times 
l Occurs 1 times 
n Occurs 3 times 
o Occurs 1 times




                                       

Anonymous

Developer

This is created by GAVASKAR .

0 comments:

Post a Comment