Censor


#1

so apparently my if statement isn't doing anything since it's just returning the same text as the argument. any suggestions?

def censor(text, word):
    new = text.split()
    stars = "*" * len(word)
    for i in range(len(new)):
        if i == word:
            new[i] = stars
    return " ".join(new)
print censor("my name is stupid you big stupid", "stupid")

#2

You are very nearly there, and on the right track. Check the line below this one.

if new[i] == ...

#3

dang! good eye mate, i knew it was something simple


#4

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