Prints all string index positions for a specific character… here is a solution to the problem.
Prints all string index positions for a specific character
If I have a string
e.g. s = '1084271054'
and want to print the index position of all 0s, for example:
0 - 1, 7
What is the most basic way to solve this problem?
Solution
[i for i, c in enumerate(s) if c=='0']
Out: [1, 7]