In another thread (Python splitting list based on missing numbers in a sequence) I found this solution:
data = [1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
for k, g in groupby(enumerate(data), lambda (i,x):i-x):
print map(itemgetter(1), g)
I am new to Python and tried to adapt it to Python 3.4:
for k, g in groupby(enumerate(data), lambda i,x :i-x):
print('%s' % list(map(itemgetter(1), g)))
I am getting this error:
<lambda>() missing 1 required positional argument: 'x'
My (limited) understanding is that the key function in the groupby statement is still linked to the lambda function requiring two arguments. Is that right? More importantly, is there a way to adapt the above code? It is a very elegant and compact solution.