from itertools import groupby
>>> l = [['a',5], ['e',5], ['c',3], ['d',3],['e',1]]
for k, v in groupby(l, lambda x: x[1]):
... ... print([a for a, _ in v] + [k])
...
['a', 'e', 5]
['c', 'd', 3]
['e', 1]
python
built-in
module has many good functions.
I recommend you take a look at what's there.
777 GDB gets version error when attempting to debug with the Presense SDK (IDE)
790 M2 Mac fails to install rbenv install 3.1.3 due to errors
869 Uncaught (inpromise) Error on Electron: An object could not be cloned
1258 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2025 OneMinuteCode. All rights reserved.