my_str = "We are here to help"
print(my_str[4]) #prints 'r'
print(my_str[7]) #prints 'h'
In the code snippet, there is a variable my_str which contains the characters string. We are getting the characters from the string like we get items from arrays using an index.
If we want to get the 8th character from the given string then we will use the syntax:
my_str[8]
0 Comments