

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Algorithm
Step 1: Define a string. Step 2: Use the replace function to remove the substring from the given string.
Example Code
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
- Related Questions & Answers
- How to extract certain substring from a string using Java?
- Program to remove duplicate characters from a given string in Python
- Write a program in Python to find the maximum length of a string in a given Series
- How to remove certain characters from a string in C++?
- Python Program to check if a substring is present in a given string.
- Remove all duplicates from a given string in Python
- Program to find length of longest repeating substring in a string in Python
- Write a program in Python to remove first duplicate rows in a given dataframe
- How do I remove a substring from the end of a string in Python?
- Write a program in C++ to remove duplicates from a given array of prime numbers
- Program to find a good string from a given string in Python
- Remove a Given Word from a String using C++
- Java program to remove all the white spaces from a given string
- How to extract a substring from inside a string in Python?
- What is an efficient way to repeat a string to a certain length in Python?
Advertisements