Skip to content

How to remove last character from Python string?


We can use the slicing in Python to remove the last character from a string in Python.

name = 'Poopcode'
print(name[:-1]) #Poopcod
print(name[:-2]) #Poopco
See also  Rank sort a list of dictionaries based on a value in Python

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.