How to Start Slice From End of String in Python


In this example, we will learn how to start the slice from the end of the string using negative indexes in Python.

Source Code

my_str = 'Python'

print(my_str[-5:-2])

Output:

yth
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement