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  Python code snippet - How to skip iteration?

Leave a Reply

Your email address will not be published.

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