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

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


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", "")



C++ is a  programming language


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