1

I have a list that looks like this:

test = [1,2,3,4,65,66,67,68,69,72,85,86,87,88,89,91]

I want to return multiple lists with sequential numbers:

[1,2,3,4]
[65,66,67,68,69]
[72]
[85,86,87,88,89]
[91]

Is there an easy way to do this in Python?

Peter Wood
  • 23,859
  • 5
  • 60
  • 99
myname
  • 1,337
  • 2
  • 11
  • 17
  • 2
    did you try anything already? – Astrom Apr 14 '17 at 20:03
  • 1
    http://stackoverflow.com/questions/2154249/identify-groups-of-continuous-numbers-in-a-list and http://stackoverflow.com/questions/2361945/detecting-consecutive-integers-in-a-list and http://stackoverflow.com/questions/7352684/how-to-find-the-groups-of-consecutive-elements-from-an-array-in-numpy – Chuck Apr 14 '17 at 20:03

0 Answers0