2016-03-04 19:03:09

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.

2016-03-04 22:36:05

This works:

box = 'bookkeeper'
prev = ''
new = ''
for a in box:
    if a != prev:
        new += a
    prev = a

print new
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2016-03-05 14:22:49

Awesome! Thanks much.