When I was working on a project where I had to clean up user IDs in a database. Some IDs had unwanted characters at specific positions.
The challenge was simple: remove a character from a string at a given index. Since Python strings are immutable, we cannot directly delete characters. But with a few tricks, we can get it done quickly.
In this tutorial, I’ll show you five simple methods I use to remove a character from a Python string by index. Each method comes with code examples so you can try them right away.
Method 1 – Remove Character by Index Using String Slicing
The easiest way is to use slicing. Since strings are immutable, we create a new string by combining the parts before and after the index.
# Remove character by index using slicing
def remove_char_by_index(text, index):
return text[:index] + text[index+1:]
# Example
city = "NewYork"
result = remove_char_by_index(city, 3)
print("Original:", city)
print("After removing character at index 3:", result)Output:
Original: NewYork
After removing character at index 3: NeworkYou can refer to the screenshot below to see the output.

This method is simple and fast, but it creates a new string every time. Still, for most cases, it’s the go-to solution.
Method 2 – Remove Character by Index Using a Loop
Another way is to loop through the Python string and rebuild it, skipping the character at the given index.
# Remove character by index using a loop
def remove_char_by_index_loop(text, index):
new_text = ""
for i in range(len(text)):
if i != index:
new_text += text[i]
return new_text
# Example
state = "California"
result = remove_char_by_index_loop(state, 5)
print("Original:", state)
print("After removing character at index 5:", result)Output:
Original: California
After removing character at index 5: CalifrniaYou can refer to the screenshot below to see the output.

I use this when I want more control, like applying conditions while removing characters. It’s not as efficient as slicing, but it’s beginner-friendly and easy to understand.
Method 3 – Remove Character by Index Using List and Join
Since strings are immutable, converting them into a list makes it easier to manipulate characters.
# Remove character by index using list and join
def remove_char_by_index_list(text, index):
text_list = list(text)
del text_list[index]
return ''.join(text_list)
# Example
zipcode = "90210"
result = remove_char_by_index_list(zipcode, 2)
print("Original:", zipcode)
print("After removing character at index 2:", result)Output:
Original: 90210
After removing character at index 2: 9010You can refer to the screenshot below to see the output.

This method is handy when you need multiple removals. Lists are mutable, so you can delete characters easily before joining them back. It’s a bit longer than slicing, but very flexible for bulk operations.
Method 4 – Remove Character by Index Using Replace
If you know the character at the index, you can use replace(). But you need to be careful because replace() removes all occurrences, not just one.
# Remove character by index using replace
def remove_char_by_index_replace(text, index):
return text.replace(text[index], "", 1)
# Example
word = "Boston"
result = remove_char_by_index_replace(word, 2)
print("Original:", word)
print("After removing character at index 2:", result)Output:
Original: Boston
After removing character at index 2: BotonYou can see the output in the screenshot below to see the output.

I use this when I want to remove only the first occurrence of a character. It’s quick, but not ideal if the same character appears multiple times in the string.
Method 5 – Remove Character by Index Using Regex
For advanced cases, regular expressions (regex) can help. We can match the character at a specific index and remove it.
import re
# Remove character by index using regex
def remove_char_by_index_regex(text, index):
return re.sub(r'(?<=^.{%d}).' % index, '', text)
# Example
address = "123MainSt"
result = remove_char_by_index_regex(address, 3)
print("Original:", address)
print("After removing character at index 3:", result)Output:
Original: 123MainSt
After removing character at index 3: 12MainStYou can refer to the screenshot below to see the output.

Regex is powerful when dealing with patterns, not just simple removals. It’s a bit overkill for small tasks, but very useful in text-cleaning projects.
So these are five practical ways I use to remove a character from a Python string by index.
The slicing method is my personal favorite because it’s short and efficient. But depending on the situation, loops, lists, replace, or regex might be more suitable.
I hope you found this tutorial helpful. Try out these methods in your own projects, and you’ll see how flexible Python string manipulation can be.
You may also read other tutorials on Python:
- PDFFileWriter Python Examples
- Convert a Python File to an EXE Using Pyinstaller
- Copy File and Rename in Python
- Import a Class from a File in Python

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.