Skip to content

How to remove last character from Python string?

Advertisements

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

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.