Censor question



For some reason when I run my code, it shows this: Oops, try again. Your function fails on censor("hey hey hey","hey"). It returns "*** *** " when it should return " *** ***".

I feel like that's kind of weird because I did exactly what the pormpt wanted me to do.

Replace this line with your code. 
def censor(text, word):
    centext = []
    spl = text.split()
    for wo in spl:
        if wo == word:
            wo = "*" * len(wo)
            wo = wo
        final = "  ".join(centext)
    return final


your code has one extra space:

final = " ".join(centext)

just remove single space then your code should work fine.


thanks soo much.
that was a silly mistake


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.