If you want to group elements in a list by a key, use itertools.groupby
. In the example above, I grouped elements in the list by the first element in each tuple.
If you want to group elements in a list by a key, use itertools.groupby
. In the example above, I grouped elements in the list by the first element in each tuple.