Skip to content

Instantly share code, notes, and snippets.

@kevinslin
Last active December 12, 2015 12:29
Show Gist options
  • Save kevinslin/4772728 to your computer and use it in GitHub Desktop.
Save kevinslin/4772728 to your computer and use it in GitHub Desktop.
#python #unsorted
# http://stackoverflow.com/questions/14721406/pythonic-way-to-determine-whether-not-null-list-entries-are-continuous?newsletter=1&nlcode=83359%7c512e
from itertools import groupby
def contiguous(seq):
return sum(1 for k,g in groupby(seq, lambda x: x is not None) if k) == 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment