I have to remove duplicate values from a string,in which child values are separated by a delimiter. My sample string is like "aa~*yt~*cc~*aa"
where ~* is the delimiter and need to remove duplcate occurence of aa
I Tried using set cmmand and below code also, but they are giving output as
"a~*ytc"
However I need the output :
"aa~*yt~*cc"
d = {}
s="aa~*yt~*cc~*aa"
res=[]
for c in s:
if c not in d:
res.append(c)
d[c]=1
print ("".join(res))
I have gone through many answers provided, but could not able to solve this. Please let me if there is any solution to it. Thanks and really appreciate your time :)