Hi gang. I have been driven insane by this for quite some time now. What we essentally want to do is remove the first duplicate in a string, but if there is space between characters, that would not be a duplicate. Thus, bookkeeper would return bokeper.
My code that I have now doesn't do that, bookkeeper comes out bokepr, which is really close; I am missing that detail that brings the code to a nice conclusion.
My code is as follows:
remove_repeat(message):
seen_chars = []
placeholder = []
for c in message:
if c not in seen_chars:
seen_chars.append(c)
if c not in placeholder:
placeholder.append(c)
return placeholder
I will change placeholder to a string as soon as i can figure out how to fix the nonconsecutive duplicate issue.
Pages 1