Normally, you would just do:

s = s[:-3] + s[-2:]

The s[:-3] gives you a string up to, but not including, the comma you want removed ("this is a string") and the s[-2:] gives you another string starting one character beyond that comma (" a").

Then, joining the two strings together gives you what you were after ("this is a string a").

Answer from Anurag Uniyal on Stack Overflow
🌐
W3Schools
w3schools.com › python › gloss_python_string_slice.asp
Python Slice Strings
Remove List Duplicates Reverse a String Add Two Numbers · Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... You can return a range of characters by using the slice syntax.
🌐
GeeksforGeeks
geeksforgeeks.org › python › string-slicing-in-python
String Slicing in Python - GeeksforGeeks
String slicing in Python is a way to get specific parts of a string by using start, end and step values. It’s especially useful for text manipulation and data parsing. ... Explanation: In this example, we used the slice s[0:5] to obtain the ...
Published   July 12, 2025
Discussions

python - Ways to slice a string? - Stack Overflow
I have a string, example: s = "this is a string, a" Where a ',' (comma) will always be the 3rd to the last character, aka s[-3]. I am thinking of ways to remove the ',' but can only think of conv... More on stackoverflow.com
🌐 stackoverflow.com
A Comprehensive Guide to Slicing in Python
The start/end indexing when going in reverse has always taken a level of extra mental effort that I don't like. Like excluding the first and last item using [1:-1] is intuitive to me, but doing the same in reverse by doing [-2:0:-1] annoys me (though I do get why its like that). That is why I tend to do [1:-1][::-1] instead. More on reddit.com
🌐 r/Python
40
356
February 1, 2022
Advanced slicing rules?
So I’m taking a quiz and the first question asks something that was never written or spoken once in the section on lists as they pertain to slicing… which is absolutely infuriating as I am someone who tries to understand EVERYTHING before moving on: Question 1: What are the values of list_b ... More on discuss.python.org
🌐 discuss.python.org
19
1
August 14, 2022
Doubt in String Slicing
Hello Everyone, I am having a doubt regarding String Slicing, so what I actually need is that for an example if the word “Happy” is the actual content and I need to work with String slicing as that I need to print with required following output as H y Ha py Hap ppy Happ appy Happy Happy ... More on discuss.python.org
🌐 discuss.python.org
10
0
July 7, 2022
🌐
W3Schools
w3schools.com › python › python_strings_slicing.asp
Python - Slicing Strings
Remove List Duplicates Reverse a String Add Two Numbers · Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ... You can return a range of characters by using the slice syntax.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-slice-string
Python slice string | DigitalOcean
August 3, 2022 - Python String slicing always follows this rule: s[:i] + s[i:] == s for any index ‘i’. All these parameters are optional - start_pos default value is 0, the end_pos default value is the length of string and step default value is 1. Let’s look at some simple examples of string slice function to create substring.
🌐
Linode
linode.com › docs › guides › how-to-slice-and-index-strings-in-python
How to Slice and Index Strings in Python | Linode Docs
January 28, 2022 - Python string indexing can also be used to extract a substring from a larger string. This process is referred to as slicing. To use Python to slice a string from a parent string, indicate the range of the slice using a start index and an end index.
Find elsewhere
🌐
InterServer
interserver.net › home › python › how to slice strings in python: step-by-step tutorial
How to Slice Strings in Python: Step-by-Step Tutorial - Interserver Tips
April 23, 2026 - The step parameter lets you skip characters in a string. It is written as the third value in the slice: [start:stop:step]. For example, if text = "PythonProgramming", you can get every second character using:
🌐
Real Python
realpython.com › lessons › string-slicing
String Slicing (Video) – Real Python
Join us and get access to thousands of tutorials and a community of expert Pythonistas. ... In the previous lesson, you saw how you could access individual characters in a string using indexing. In this lesson, you’ll learn how to expand that syntax to extract substrings from a string. This technique is known as string slicing. You’ll practice with the standard syntax, and learn how omitting the first or last index extends the slice.
Published   October 1, 2019
🌐
CodeHS
codehs.com › tutorial › 13739
Tutorial: Slicing Python Strings | CodeHS
Python Tutorial · python · By Ryan Molyneaux · High School · python · By Ryan Molyneaux · High School · All Products · Coding LMS · Online IDE · CodeHS Pro · Computer Science Curriculum · Certifications · Professional Development · AI Creator ·
🌐
Reddit
reddit.com › r/python › a comprehensive guide to slicing in python
r/Python on Reddit: A Comprehensive Guide to Slicing in Python
February 1, 2022 - I can relate to this! I also use `[...][...]` (two-slice) notation most of the time for these cases.
🌐
Medium
jzamiski.medium.com › the-basics-of-string-slicing-in-python-56a248304991
The Basics of String Slicing in Python | by Joey Zamiski | Medium
January 3, 2021 - The code above defines Python’s string slicing syntax as: string[start index : end index]. Starting index is always included. This means that the starting index you provide is the character index that is used to begin the production of the substring. However, end index is excluded.
🌐
freeCodeCamp
freecodecamp.org › news › slicing-and-indexing-in-python
Slicing and Indexing in Python – Explained with Examples
December 11, 2025 - In these examples, we have used slicing to extract a range of characters from the sentence string. The 4:9 slice means that we are selecting characters starting from index 4 (inclusive) up to index 9 (exclusive), which correspond to the second word "quick".
🌐
Python.org
discuss.python.org › python help
Advanced slicing rules? - Python Help - Discussions on Python.org
August 14, 2022 - So I’m taking a quiz and the first question asks something that was never written or spoken once in the section on lists as they pertain to slicing… which is absolutely infuriating as I am someone who tries to understand EVERYTHING before moving on: Question 1: What are the values of list_b ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-index-and-slice-strings-in-python
How to Index and Slice Strings in Python? - GeeksforGeeks
July 15, 2025 - In Python, indexing and slicing are techniques used to access specific characters or parts of a string.
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › brackets › slicing.html
[] (slicing) — Python Reference (The Right Way) 0.1 documentation
O(n+k) for slice assignment · Consider the following ASCII graph showing the contents of the “ABCD” string: >>> +---+---+---+---+ >>> |-4 |-3 |-2 |-1 | <= negative indexes >>> +---+---+---+---+ >>> | A | B | C | D | <= sequence elements >>> +---+---+---+---+ >>> | 0 | 1 | 2 | 3 | <= positive indexes >>> +---+---+---+---+ >>> |<- 0:3:1 ->| <= extent of the slice: "ABCD"[0:3:1] Consider the following example: >>> "ABCD"[0:2] 'AB' It can be read as: get every single one item between indexes 0 and 2 (exclusive).
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › string slicing in python
String Slicing in Python
October 22, 2024 - ... When you slice a string, you specify the start and end indices to indicate the portion of the string you want to extract. Python then creates a new string containing the characters between these indices.
🌐
Python.org
discuss.python.org › python help
Doubt in String Slicing - Python Help - Discussions on Python.org
July 7, 2022 - Hello Everyone, I am having a doubt regarding String Slicing, so what I actually need is that for an example if the word “Happy” is the actual content and I need to work with String slicing as that I need to print with required following output as H y Ha py Hap ppy Happ appy Happy Happy so the above results is the required one and I need a simple code to get this to be printed.
🌐
LearnPython.com
learnpython.com › blog › string-slicing-in-python
String Slicing in Python: A Complete Guide | LearnPython.com
Another way of slicing a string in Python is the slice() function. It returns a slice object representing the set of indices specified by start, stop, and step parameter. Slice objects contain a portion of a sequence.