How to Remove Letters From a String in Python Last Updated : 27 Oct, 2025 Comments Improve Suggest changes 55 Likes Like Report Given a string, the task is to remove one or more specific letters from it. Since Python strings are immutable, a new string must be created after removing characters.For example:Input: "hello world"Remove: "l"Output: "heo word"Let’s explore different methods to remove letters from a string in Python.Using replace()The replace() method replaces all occurrences of a character with another replacing it with an empty string effectively removes it. Python s = "hello world" s = s.replace("l", "") print(s) Outputheo word Explanation: s.replace("l", "") replaces every "l" with an empty string "".Since replacement creates a new string, the original remains unchanged.Using filter() functionfilter() function provides an efficient way to filter out characters based on a condition. It returns an iterator, which can be converted back to a string. Python s = "hello world" s = "".join(filter(lambda c: c != "o", s)) print(s) Outputhell wrld Explanation:filter(lambda c: c != "o", s) checks every character in s and removes 'o'.join() merges the remaining characters back into a single string.Works well for both letters and conditions (like removing vowels, digits, etc.).Using Regular ExpressionsFor more advanced removal, such as removing multiple letters or patterns, the re.sub() method can be used. It is used for pattern-based deletions. Python import re s = "hello world" s = re.sub("[aeiou]", "", s) print(s) Outputhll wrld Explanation:re.sub("[aeiou]", "", s) removes all vowels.The pattern [aeiou] matches any vowel, and "" replaces them with nothing.Using list comprehensionList comprehension provides a more concise way to remove specific characters from a string than the loop method. Python s = "hello world" s = "".join([c for c in s if c != "o"]) print(s) Outputhell wrld Explanation:[c for c in s if c != "o"] generates a list of characters in s but excludes "o"."".join(...) combines the list back into a string.Related Articles:Remove Letters Using Regular Expressions Create Quiz Comment M manjeet_04 Follow 55 Improve M manjeet_04 Follow 55 Improve Article Tags : Python python-string Python string-programs Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 4 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 3 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 3 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 3 min read StatsModel Library - Tutorial 3 min read Learning Model Building in Scikit-learn 6 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 5 min read Build a REST API using Flask - Python 3 min read Building a Simple API with Django REST Framework 3 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like