3 ways to get the last characters of a string in Python

Renesh Bedre    1 minute read

In this article, I will discuss how to get the last any number of characters from a string using Python

Using numeric index

The numeric string index in Python is zero-based i.e., the first character of the string starts with 0. If you know the length of the string, you can easily get the last character of the string

Get last character using positive index


Get the last character using negative index (the last character starts at -1)


Using string slices

Get the last character in a string,


# using negative index

Get the last few character in a string,

# get last 2 characters

# using negative index

Using list

Strings can be converted to lists to access the individual characters in a string

# get last character

Learn more about Python

If you have any questions, comments or recommendations, please email me at reneshbe@gmail.com

Subscribe to get new article to your email when published

* indicates required

This work is licensed under a Creative Commons Attribution 4.0 International License