Collection of less popular features and tricks for the Python programming language
Geek Repo:Geek Repo
Github PK Tool:Github PK Tool
shellvon opened this issue 9 years ago · comments
grouping adjacent use zip and iter... some code like this:
lst = range(10) group_n = lambda lst, n: zip(*([iter(lst)] * n)) print group(lst, 3) #output #[(0, 1, 2), (3, 4, 5), (6, 7, 8)]