Answer to Question #227025 in Python for hari

Question #227025

Input: aabbhayy

Output: A2B2H1A1Y2

Note : please solve the above coding problem in python.



1
Expert's answer
2021-08-17T16:53:37-0400
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS