Finding duplicates with count in string

st1 = “good morning”
for s in range(0, len(st1)):
count = 1;
for t in range(s+1, len(st1)):
if(st1[s] == st1[t] and st1[s] != ’ '):
count = count + 1
st1 = st1[:t] + ‘0’ + st1[t+1:]
if(count > 1 and st1[s] != ‘0’):
print(st1[s]," - ",count);

1 Like

@mick4mayank

Well done. Keep it up.

1 Like