0

I was running the example at

Detecting consecutive integers in a list

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 ix: ix[0] - ix[1]):
    result = list(map(itemgetter(1), g))
    print (result)

    for t in g:
        print(t)

but the 2nd print in the loop could not print anything out.

why is that

daiyue
  • 7,196
  • 25
  • 82
  • 149

0 Answers0