Tranform of input array of zeros and ones to array in which counts number of continuous ones:

[1, 1, 1, 0, 1] -> [3,1]

Difficulty: introductory

Starter code:

def ones_counter(input):
	

Solutions:
from itertools import groupby


def ones_counter(nums):
    return [sum(g) for k, g in groupby(nums) if k]


import itertools as it

def ones_counter(ar):
    return [len(list(group)) for bit, group in it.groupby(ar) if bit == 1]


def ones_counter(input):
    return [i.count('1') for i in ''.join(map(str, input)).split('0') if i]

def ones_counter(input):
    s = ''.join(str(i) for i in input).split('0')
    return [ [len(i) for i in s if len(i)], [] ] [1 not in input]

def ones_counter(input):
    return [ele.count('1') for ele in ''.join(map(str,input)).split('0') if ele.count('1')]

from itertools import groupby

def ones_counter(lst):
    return [len(list(b)) for a, b in groupby(lst) if a]

from itertools import groupby


def ones_counter(nums):
    return [sum(1 for b in g) for k, g in groupby(nums) if k]


from itertools import groupby

def ones_counter(xs):
    return [sum(g) for x, g in groupby(xs) if x == 1]

def ones_counter(input):
    c, result = 0, []
    for x in input + [0]:
        if x != 1 and c != 0:
            result.append(c)
            c = 0
        elif x == 1:
            c += 1
    return result

def ones_counter(a):
    r = [0]
    for x in a:
        if x == 1:
            r[-1] += 1
        else:
            if r[-1]: r.append(0)
    return [x for x in r if x]