Simple:

my_str =  "abcdefghij"
my_str = my_str[:-1]

Try the following code snippet to better understand how it works by casting the string as a list:

str1 = "abcdefghij"
list1 = list(str1)
print(list1)
list2 = list1[:-1]
print(list2)

In case, you want to accept the string from the user:

str1 = input("Enter :")
list1 = list(str1)
print(list1)
list2 = list1[:-1]
print(list2)

To make it take away the last word from a sentence (with words separated by whitespace like space):

str1 = input("Enter :")
list1 = str1.split()
print(list1)
list2 = list1[:-1]
print(list2)
Answer from Cyrille on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-program-to-remove-last-character-from-the-string
Python program to Remove Last character from the string - GeeksforGeeks
July 11, 2025 - ... Str = "GeeksForGeeks" # Using positive indexing print(Str[:len(Str) - 1]) Str = "GeeksForGeeks" # Using negative indexing print( Str[:-1]) ... Str[:len(Str) - 1] removes last character by slicing up to second last index.
Discussions

5 Ways You Can Remove Last Character From String in Python
Method 1 and 2 are the same, except that defining a variable that doesn't do anything but hold the length of string 1 is even a bit more inefficient than method 1. Importing the re module to remove a character from a string is just ridiculous. Also it's not removing the last character, but deleting all 'n's. Could have achieved the same with the built-in str.replace() method. str.rstrip() isn't used correctly. It won't remove the last character, but will also shorten 'helloooooo' to 'hell'. The loop also removes all 'n's, not necessarily the last character. Plus it is highly inefficient and not pythonic in any way More on reddit.com
🌐 r/programming
3
0
July 19, 2021
How to remove last two characters from strings under a Dataframe column
You can use the str() method in Pandas to remove the last 2 characters from all values in a particular column: df["Index"] = df["Index"].str[:-2] More on reddit.com
🌐 r/learnpython
4
1
June 13, 2022
How do you remove the first and last character from a string?
new_word = word[1:-1] More on reddit.com
🌐 r/learnpython
4
2
March 25, 2021
Removing the last character in a string
\.$ $ means end of string. You may have to enable multi line mode if this is one string. https://regex101.com/r/VbcHWT/1 More on reddit.com
🌐 r/regex
7
0
June 5, 2022
People also ask

Can Python strings be changed in place?
No. Strings are immutable, so save the result of slicing or removesuffix() in a new variable or return it from a helper.
🌐
pythonpool.com
pythonpool.com › home › tutorials › remove the last character from a python string safely
5 Ways to Remove the Last Character From String in Python
Why should I avoid rstrip() for one character?
rstrip() removes any number of trailing characters from a supplied set, while slicing removes exactly one final character.
🌐
pythonpool.com
pythonpool.com › home › tutorials › remove the last character from a python string safely
5 Ways to Remove the Last Character From String in Python
How do I remove only a trailing newline?
Use text.removesuffix('\n') so real content is not removed when the final line does not contain a newline.
🌐
pythonpool.com
pythonpool.com › home › tutorials › remove the last character from a python string safely
5 Ways to Remove the Last Character From String in Python
🌐
Codecademy
codecademy.com › article › remove-characters-from-a-python-string
How to Remove Characters from a String in Python | Codecademy
String slicing is a useful feature in Python that enables us to extract a portion of a string using index positions. We can use this feature to remove the last character from a string.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-remove-last-character-in-list-of-strings
Python | Remove last character in list of strings - GeeksforGeeks
May 18, 2023 - The rsplit() method splits a string from the right, starting at the last character. By passing 1 as the only argument, it returns a list with the original string as the first element, and the last character as the second element. Then, we use string slicing to remove the last character and store the modified strings in the res list.
🌐
Medium
medium.com › @ryan_forrester_ › remove-the-last-character-from-a-string-in-python-a16000d6c102
Remove the Last Character from a String in Python | by ryan | Medium
January 7, 2025 - The fastest and most readable way to remove the last character from a string is using Python’s slice notation:
🌐
Python Pool
pythonpool.com › home › tutorials › remove the last character from a python string safely
5 Ways to Remove the Last Character From String in Python
July 13, 2026 - Since rstrip() can remove several trailing characters, it may turn "code..." into "code" when you intended "code..". The second mistake is slicing a file line without checking whether a newline exists. If the final line has no newline, line[:-1] removes real content. Use removesuffix("\n") when the newline itself is the target. The third mistake is forgetting that slices return new strings.
Find elsewhere
🌐
Snakify
snakify.org › strings
Strings - Learn Python 3 - Snakify
For example, to remove the first ... of the string. That is, to remove the last character from the string, you can use slice S[:-1]. The slice S[:] matches the string S itself....
🌐
Data Science Parichay
datascienceparichay.com › home › blog › remove last character from string in python
Remove Last Character From String in Python - Data Science Parichay
December 14, 2021 - The simplest way to remove the last character from a string in Python is to slice the string from the first character to the second last character.
🌐
Reddit
reddit.com › r/programming › 5 ways you can remove last character from string in python
r/programming on Reddit: 5 Ways You Can Remove Last Character From String in Python
July 19, 2021 - eek, not what we wanted! So in practice I always use re.sub, which you can be much more specific to specify start/end of the string, and exactly what to replace.
🌐
Career Karma
careerkarma.com › blog › python › python: remove last character from string
Python: Remove Last Character from String | Career Karma
December 1, 2023 - Slicing syntax lets you delete the last character from a string object in Python. All you need to do is specify a string and add [:-1] after the string. Now you’re ready to remove the last character from a Python string like an expert!
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python remove last character from string
Python Remove Last Character From String - Spark By {Examples}
May 21, 2024 - How to remove the last character from a string in Python? String manipulation is indeed one of the most important features of Python, and knowing various
🌐
Python Guides
pythonguides.com › remove-the-last-character-from-a-string-in-python
Remove Last Character from String in Python
August 20, 2025 - This is a real-world case where removing the last character makes the dataset clean and ready for analysis. Empty Strings: If the string is empty, slicing or regex will still work, but you should handle it to avoid unexpected results. Performance: For large datasets, slicing is the fastest method. Python Version: If you’re using removesuffix(), make sure you’re on Python 3.9 or later.
🌐
Geekflare
geekflare.com › development › how to remove last character from python string?
How to Remove Last Character from Python String?
January 20, 2025 - As a traditional slicing, it extracts the substring from the starting index to last but one as slicing ignores the second index element given. You will get Geekflare as output if you run the above code. The string method rstrip removes the characters from the right side of the string that is given to it.
🌐
Kodeclik
kodeclik.com › python-remove-last-character-from-string
How to remove the last character from a Python string
September 24, 2024 - A very simple modification to the above program achieves this goal: name = "Kodeclik Online Academy." print(name[:-1]) ... The second approach to removing the last character from a Python string uses the built-in function rstrip().
🌐
Delft Stack
delftstack.com › home › howto › python › how to remove last character from string in python
How to Remove the Last Character From String in Python | Delft Stack
February 2, 2024 - import re def rmve_2nd_grp(b): return b.group(1) my_str = "Python String" result = re.sub("(.*)(.{3}$)", rmve_2nd_grp, my_str) print(result) In the code, the sub() method compares the defined pattern and passed that similar object to the method rmve_2nd_grp(). The matched object has two groups, but rmve_2nd_grp() compares characters from group1 and gives back the string.
🌐
RS Blog
reneshbedre.com › blog › remove-last-characters-string.html
3 easy ways to remove the last characters of a string in Python
August 18, 2021 - x[:len(x)-1] # Note: -1 is equivalent len(x)-1 'ATGCATTT' # Remove last 2 characters x[:len(x)-2] 'ATGCATT' If you know the last character of a string, you can use the rstrip() function ... Learn how to find the maximum and minimum sequence lengths in a FASTA file using Python, seqkit, and samtools
🌐
Career Karma
careerkarma.com › blog › python › python remove character from string: a guide
Python Remove Character from String: A Guide | Career Karma
December 1, 2023 - We are using a Python list ... we specified from our string. To remove the last character from a string, use the [:-1] slice notation....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-program-to-remove-last-n-characters-from-a-string
Python program to remove last N characters from a string - GeeksforGeeks
July 23, 2025 - This approach iterates through ... the last N characters. The rstrip method, combined with conditions, allows us to remove the last N characters by treating them as a specific substring to strip....
🌐
Plain English
plainenglish.io › home › blog › python › 5 ways you can remove the last character from a string in python
5 Ways You Can Remove the Last Character from a String in Python
June 2, 2021 - The rstrip method is used to remove or delete the characters from the right side of the string, so we can easily remove the last character from the string using rstrip function. For a better understanding, let’s look into the example.