How to delete a character from a string using Python?

Posted by Editorial Staff | Updated on

If you want to delete a character at a certain index from the string, you can use string slicing to create a string without that character. In Python, strings are immutable, so you have to create a new string. You have a few options of how to create the new string. If you want to remove the ‘M’ wherever it appears:

If you want to remove the central character:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers