Today we are going to share a Python program to remove a word from the sentence. If you are a python beginner and want to start learning the python programming, then keep your close attention in this program.
Want to increase your Python knowledge, practice all Python programs, here is a collection of 100+ Python problems with solutions.
Copy the below python program and execute it with the help of python compiler.
1 2 3 4 5 6 7 8 9 10 |
print("Enter 'x' for exit."); string = input("Enter any string to remove particular word: "); if string == 'x': exit(); else: word = input("Enter word to be delete/remove: "); print("\nDeleting given word from the given string..."); print("New String after successfully deleting",word); word_list = string.split(); print(' '.join([i for i in word_list if i not in word])); |
Enter any string to remove particular word: This is an example of the python program.
Enter word to be delete/remove: the
Deleting given word from the given string…
New String after successfully deleting ‘This is an example of python program.’
Same program in different programming langugaes:
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.