Python - How to find 'repeat' characters in a string? -
this question has answer here:
- find occurrences of character in string 6 answers
- find occurrences of substring in python 10 answers
for example in 'gattaca' want find 'a's.
i want positions 1,4,6.
using '.find' method gives me location of first 'a' not rest.
i wondering if there method allowed find 'repeat' characters in string?
in [26]: s = 'gattaca' in [27]: [i i,char in enumerate(s) if char=="a"] out[27]: [1, 4, 6]
Comments
Post a Comment