Skip to content

Instantly share code, notes, and snippets.

@FerdinaKusumah
Last active July 28, 2020 14:12
Show Gist options
  • Save FerdinaKusumah/e96cbeef5d4b4bf496926a949027407e to your computer and use it in GitHub Desktop.
Save FerdinaKusumah/e96cbeef5d4b4bf496926a949027407e to your computer and use it in GitHub Desktop.
[Python] Grouping consecutive value
from itertools import groupby
"""grouping value based on consecutive value"""
num = "aaabbccc"
group_value = list(list(val) for _, val in groupby(num))
# group value is [['a', 'a', 'a'], ['b', 'b'], ['c', 'c', 'c']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment