Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Group Equal consecutive by Tashka
def group_equal(elements):
if not elements:
return []
final_lst = [[elements[0]]]
if len(elements) > 1:
for i in range(1, len(elements)):
if elements[i] != elements[i-1]:
final_lst.append([elements[i]])
else:
final_lst[-1].append(elements[i])
return final_lst
Dec. 9, 2019