Censor


#1

please help me get my code right

def censor(text,word):
    l=[]
    
    for x in text:
        if x in word:
        
            l.append("*")
        else:
            l.append(x)
    return "".join(l)
print censor("my name is sam plz help sam","sam")

#2

your design of your program is a bit off

you want to censor sam in my name is sam plz help sam, you don't want to censor all the letters s, a and m which is what you are currently doing

your output:

*y n**e i* *** plz help ***

desired output:

my name is *** plz help ***

maybe you can check the hint in the lesson? start by using .split() so you have the separate words in text string


#3

yeah you are ryt hint helped correct my mistake thanx anyways!

def censor(text,word):
l=[]

n=text.split()
print n
for x in n:
    if x in n==word:
        l.append("*"*len(word))
    else:
        l.append(x)
return "".join(l)

print censor("my name is sam yeah sam","sam")


#4