Python itertools.groupby() Function
The itertools.groupby() function groups consecutive elements that have the same key value.
Syntax
itertools.groupby(iterable, key=None)
Return Value
An iterator of (key, group) tuples.
Example
Output
Click Run to execute your code