This post will discuss how to remove the last character from a string in Python.

1. Using Slicing

A simple approach to remove the last character from a string is using slicing.

Download  Run Code

 
If you want to remove the last n characters, you can do:

Download  Run Code

2. Using rstrip() function

If you need to remove all occurrence of a trailing character, you can use the rstrip function:

Download  Run Code

That’s all about removing the last character from a string in Python.