Censor question


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/4?curriculum_id=4f89dab3d788890003000096#


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)
        else:
            wo = wo
        centext.append(wo)
        final = "  ".join(centext)
    return final


#2

your code has one extra space:

final = " ".join(centext)

just remove single space then your code should work fine.


#3

thanks soo much.
that was a silly mistake


#4

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