48.7k views
0 votes
Write a python program stored in file extra_credit.py that takes three different inputs from the user where : First Input: The program takes a sentence as input from the user. Second Input: The program takes individual words separated by whitespace as input. Third Input: The program takes a single special character as input.

2 Answers

3 votes

Answer:

print("************************************************************")

sentence = input("Enter a sentence : ").split()

replace_words = input("\\Enter the words that should be replaced : ").split()

special = input("\\Enter the replacing special Character : ")

result = []

for word in sentence:

if word not in replace_words:

result.append(word)

else:

result.append(special * len(word))

result = ' '.join(result)

print("\\The Sentence with words censored is : " + result)

print("************************************************************")

User Soufiane Yakoubi
by
3.2k points
6 votes

Answer:

Check the explanation

Step-by-step explanation:

print("************************************************************")

sentence = input("Enter a sentence : ").split()

replace_words = input("\\Enter the words that should be replaced : ").split()

special = input("\\Enter the replacing special Character : ")

result = []

for word in sentence:

if word not in replace_words:

result.append(word)

else:

result.append(special * len(word))

result = ' '.join(result)

print("\\The Sentence with words censored is : " + result)

print("************************************************************")

User LouraQ
by
3.0k points