How to Access Elements of String in Python


In this example, we will learn how to access elements of the string in Python.

Source Code

my_str = 'Python'

print(my_str[2])
print(my_str[4])

Output:

t
o
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments