Created
November 8, 2021 12:15
-
-
Save scidam/146ec210b01677ad60056094fd12e53a to your computer and use it in GitHub Desktop.
Offset and fill with '*' by default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pairwise_offset(sequence, fillvalue='*', offset=0): | |
| sequence = list(sequence) | |
| a = sequence + [fillvalue] * offset if offset > 0 else [fillvalue] * offset + sequence | |
| b = [fillvalue] * offset + sequence if offset > 0 else sequence + [fillvalue] * offset | |
| return list(map(tuple, zip(a, b))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment