Python - How to find 'repeat' characters in a string? -


this question has answer here:

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

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -