I'm trying to find consecutive integers in a list, similar to the solution to this question: Detecting consecutive integers in a list
However, that question was answered in python 2, and running the same code sample in python 3 results in the following
from itertools import groupby
from operator import itemgetter
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))
File "temp.py", line 4
for k, g in groupby(enumerate(data), lambda (i, x): i-x):
^
SyntaxError: invalid syntax
I can't seem to see where the syntax would have changed between python versions, and I'm guessing I'm missing an easy fix.