python index of a char the third time code example
Example 1: python3 return a list of indexes of a specific character in a string
string='mississippi'
s='s'
lst= []
for i in range(len(string)):
if (string[i] == s):
lst.append(i)
print(lst)
#result: [2, 3, 5, 6]
Example 2: how to find the location of a character in a string in python
>>> myString = 'Position of a character'
>>> myString.find('s')
2
>>> myString.find('x')
-1