Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inStr = input("Enter a string: ")
- dic = {a:inStr.count(a) for a in inStr}
- dicRepeat = [a for a, b in dic.items() if b > 1]
- tmpStr = inStr
- for i in range(len(dicRepeat)):
- tmpLoc = tmpStr.index(str(dicRepeat[i]))
- tmpStr = tmpStr[:tmpLoc + 1] + tmpStr[(tmpLoc + 1):].replace(dicRepeat[i],"$")
- print(tmpStr)
Advertisement
Add Comment
Please, Sign In to add comment