Skip to content

Instantly share code, notes, and snippets.

@petri

petri/splicing.py

Created Apr 26, 2020
Embed
What would you like to do?
Get all ordered n-size splices of a sequence in Python
def splice(sequence, size):
"return a list of all ordered splices of given size"
ss = len(sequence)
return [sequence[i:i+size] for i in range(0, ss-size+1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.