Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python position letter in string

string = "This is a string"
position_of_letter_a = string.find('s')
    #output is 8, because the strings starts counting from 0 from left to right
position_from_the_right = string.rfind('s')
    #output is 10, because the strings starts counting from 0 and goes to the last 's' in the string
 
PREVIOUS NEXT
Tagged: #python #position #letter #string
ADD COMMENT
Topic
Name
5+5 =