Skip to content

Instantly share code, notes, and snippets.

@raeq
Created July 18, 2020 20:06
Show Gist options
  • Save raeq/e39c4b1374e3ff1ddc82a408aafc33c3 to your computer and use it in GitHub Desktop.
Save raeq/e39c4b1374e3ff1ddc82a408aafc33c3 to your computer and use it in GitHub Desktop.
Interleave two strings
import itertools
def interleave(left: str = "", right: str = "") -> str:
return "".join(
[i + j for i, j in itertools.zip_longest(left, right, fillvalue="")])
assert interleave("ABCD", "01") == "A0B1CD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment