Codility binary gap solution using indices
Converting from string to int in your first comprehension isn't needed as you're comparing to a literal anyway.
You can merge the first two comprehensions.
you don't need to return early, as you can default max to 1.
You shouldn't need the 8 in your format, as it shouldn't matter if there's padding or not, as it'll be filtered anyway.
From Python 3.6 you can use an f-string.




def solution(N):
    indices = [bit for bit, x in enumerate(f'{N:0b}') if x == '1']
    lengths = (end - beg for beg, end in zip(indices, indices[1:]))
    return max(lengths, default=1) - 1