PYTHON without def function
Given two inputs: a sentence and a word to be censored. Print out a new sentence with the word censored. In place of the censored word, print "*******", where the number of * characters match the length of the word. The program should censor the exact casing of the word.
Sample Input
Pysics is very hard!I'm very ready! Im very excited
Sample Output
Pysics is **** hard!I'm **** ready! Im **** excited
def censor_words(sentence, word): splits = sentence.split(" ") result = "" for y in splits: if y==word: result += len(y)*"*" else: result += y result += " " result = result[:-1] return result # Testing print(censor_words("Pysics is very hard!I'm very ready! Im very excited","very"))
Get Answers For Free
Most questions answered within 1 hours.