Itertools Groupby String. groupby() returns an iterator of keys and groups. By grouping ide