Last active
March 8, 2020 12:24
-
-
Save theelous3/83e204bcb3d63f738ab53be424ab0dc4 to your computer and use it in GitHub Desktop.
This file contains 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 intersperse(xs, y, gap=1, pre=False): | |
for i, x in enumerate(xs): | |
if not pre: | |
yield x | |
if not i % gap: | |
yield y | |
if pre: | |
yield x | |
list(intersperse([1, 2, 3, 4, 5, 6], "X")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment