# Write a Python program to remove a certain length substring from a given string

PythonServer Side ProgrammingProgramming

We need to write a Python program which will remove a certain substring from a given string

## Algorithm

Step 1: Define a string.
Step 2: Use the replace function to remove the substring from the given string.

## Example Code

Live Demo

original_string = "C++ is a object oriented programming language"modified_string = original_string.replace("object oriented", "")print(modified_string)

## Output

C++ is a  programming language

## Explanation

The in-build Python replace() function takes the following parameters:

• Oldstring: The string which you want to remove
• Newstring: The new string you want to replace in place of the oldstring
• Count: Optional. Number of times you want to replace the oldstring with the newstring
Updated on 16-Mar-2021 10:17:50