Write a Python program to remove substrings of a specific length from a given string
We need to write a Python program that will remove certain substrings from a given string
algorithm
Step 1: Define a string. Step 2: Use the replace function to remove the substring from the given string.
sample code
original_string = "C++ is an object oriented programming language" modified_string = original_string.replace( "object oriented" , "" )print(modified_string)
output result
C++ is a programming language
explain
The built-in Python replace() function takes the following arguments:
Oldstring: the string you want to remove
Newstring: The new string to replace the old string with
count: optional. the number of times you want to replace the old string with the new string
0 Comments