WA in "Little elephant and bombs"

I don’t know why this code gives WA for LEBOMBS. Can’t get an input in which it fails. Please, somebody can help me?

for _ in range(int(input())):
N = int(input())
S = '0' + input() + '0'

count = 0
for i in range(1, N+1):
    if S[i-1] == '0' and S[i+1] == '0' and S[i] == '0':
        count += 1

Elegant solution, I wouldn’t have thought to do it that way.
I have tried to find a bug on my own, but wasn’t able to.
When looking trough accepted solutions I found the problem:


(where “_” denotes a space)
The problem is whitespace characters before or after the string, which get recognised as bombs
After fixing that issue you will get AC

1 Like

Thank you very much, spaanse!!! You’re right! Finally got an AC with this solution!