Chunk + Enumerate a list of digits I have a list of decimal digits:

4, 4, 4, 7, 7, 9, 9, 9, 9, 2, 2, 2, 4, 4

The list of decimal digits are known as items. We can form "chunks" from these items by grouping together identical and adjacent numbers. I want to assign each chunk a unique number, starting from 1, and increasing by 1 in the order the chunks appear in the original list. So, the output for the given example would look like this:

1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5

Input format

A list of digits. (0-9) You may use your language built-ins to read this list however you want. Encoding: ASCII

Output format

A series of decimal numbers, separated by a delimiter. Your program must always use the same delimiter. The delimiter must be longer than 0 bits. Encoding: ASCII

Standard loopholes apply.
Python 3.8 (pre-release), 41 bytes



lambda l,n=0:[n:=n+(l!=(l:=x))for x in l]


Try it online!

Praise the magic walrus := of assignment expressions.



Python 2, 42 bytes



n=0
for x in input():n+=x!=id;id=x;print n


Try it online!