Input: aabbhayy
Output: A2B2H1A1Y2
Note : please solve the above coding problem in python.
n = input('Enter text here: ')
for i,v in enumerate(n):
if n[:i+1].count(v) > 1 and n[i-1] == n[i]:
j = n[0:i+1]
print(v.upper()+str(j[:i+1].count(v)),end='')
elif n[:i+1].count(v) == 1 and n[i] != n[i+1]:
print(v.upper()+'1',end='')
elif n[:i+1].count(v) >= 2 and n[i] != n[i+1]:
print(v.upper()+str(1),end='')
Enter text here: aabbhayy
A2B2H1A1Y2
Comments
Leave a comment