How to Get a Range of Characters in a String in Python


In this example we will show how to use the slice syntax to get a range of characters in a string in Python.

Source Code

my_str = 'Python'

print(my_str[1:4])

Output:

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