This Python script enables users to replace occurrences of a specific word in a given text with a new word. It's a simple utility suitable for basic text manipulation tasks.
- The script initializes with a predefined text.
- It prompts the user to input the word they want to replace (
exist_word) and the new word (new_word). - It checks if
exist_wordexists in the text. - If found, it replaces all occurrences of
exist_wordwithnew_word. - The modified text is then displayed.
To use this script:
- Clone the repository.
- Run the script (
replaceWord.py). - Follow the prompts to replace words in the provided text.
Given the text: The sun was setting over the ocean as I walked along the beach. The warm sand felt soft between my toes as I searched for interesting shells. The sound of the waves crashing against the shore was soothing, and I felt my worries slowly draining away. As I strolled, I noticed a few seagulls flying overhead, and I couldn't help but smile at their playful cries.
If you want to replace waves with breeze, you would input:
Which Word Do you want to replace: waves Give me the New Word: breeze
The output will be: The sun was setting over the ocean as I walked along the beach. The warm sand felt soft between my toes as I searched for interesting shells. The sound of the breeze crashing against the shore was soothing, and I felt my worries slowly draining away. As I strolled, I noticed a few seagulls flying overhead, and I couldn't help but smile at their playful cries.