Censor


#1

i dont understand what censor function suppose to do ?? i dont understand for real what iam suppose to do exactly?


#2

You are supposed to replace certain words from a sentence with ****.

The function allows you to use any sentence and take any word you like.
You have to figure out if your sentence contains the word you want to censor and then figure out how to replace it with **** to hide that word and print the new sentence.


#3

@letmeprogramyou1 The direction ask you to make a function in which it will take in a handful of words and another word which will censor the designated word you choose to have removed. Do you understand the instructions now?


#4

yes thanks a lot i understand i already understand before you write this thanks for help i was little confused


#6

def censor(text, word):
    k = []
    x = text.split()
    for string in x:
        if string == word:
            string = ("*" * len(string))
            k.append(string)
        else:
            k.append(string)
    final = " ".join(k) 
    print final
    return final
    
censor("Yesterday I was eating", raw_input())

I hope it helps.


#7

def censor(text,word):
string = ""
string = text.replace(word,"*" * len(word))
return string


#8

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