Skip to content

Instantly share code, notes, and snippets.

@spitz-dan-l
Last active August 29, 2015 14:02
Show Gist options
  • Save spitz-dan-l/f48b4fa9f2098705faec to your computer and use it in GitHub Desktop.
Save spitz-dan-l/f48b4fa9f2098705faec to your computer and use it in GitHub Desktop.
from itertools import chain, starmap
def remove_spans(s, spans):
to_drop = set(chain(*starmap(range, spans)))
return ''.join(c for (i, c) in enumerate(s) if i not in to_drop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment