Skip to content

This Python script allows users to replace occurrences of a specific word in a given text with a new word. It prompts the user for the word to replace and the new word, performs the replacement, and then displays the updated text.

Notifications You must be signed in to change notification settings

octo-space/Text-Replacement-Tool-in-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Text Replacement Tool in Python

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.

How it works

  1. The script initializes with a predefined text.
  2. It prompts the user to input the word they want to replace (exist_word) and the new word (new_word).
  3. It checks if exist_word exists in the text.
  4. If found, it replaces all occurrences of exist_word with new_word.
  5. The modified text is then displayed.

Usage

To use this script:

  1. Clone the repository.
  2. Run the script (replaceWord.py).
  3. Follow the prompts to replace words in the provided text.

Example

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.

About

This Python script allows users to replace occurrences of a specific word in a given text with a new word. It prompts the user for the word to replace and the new word, performs the replacement, and then displays the updated text.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages