Dec-01-2020, 04:56 PM
(This post was last modified: Dec-01-2020, 05:20 PM by Larz60+.
Edit Reason: Removed extra code tag
)
Hi everyone, I am a beginner in Python. This is a challenge that I've found in a forum. This program is censoring the words' (which has given by the user) letters with "*" except the first letter. For example, If the sentence is "Every breath you take every move you make" and the input word is "every", the output should look like this:
This was my only idea but it did not work.
Any help would be appreciated!
1 2 3 |
2 incidents found. Censored lyrics: E * * * * breath you take e * * * * move you make |
1 2 3 4 5 6 7 8 9 10 11 12 |
text = input ( "Enter your text: " ).lower() word = input ( "Choose a word from the previously entered text: " ).lower() def censor(text,word): t = text.split() n = [] for i in t: if (i = = word): n.append( "*" * len (word)) else : n.append(i) return " " .join(n) print censor(text,word) |