I want to find the index of multiple occurrences of at least two zeros followed by at least two ones (e.g., '0011','00011', '000111' and so on), from a string (called 'S') The string S may look like:
'00111001100011'
The code I tried can only spot occurrences of '0011', and strangely returns the index of the first '1'. For example for the S above, my code returns 2 instead of 0:
index = []
index = [n for n in range(len(S)) if S.find('0011', n) == n]
Then I tried to use regular expression but I the regex I found can't express the specific digit I want (like '0' and '1')
Could anyone kindly come up with a solution, and tell me why my first result returns index of '1' instead of '0'? Lot's f thanks in advance!!!!!