Created
July 18, 2020 20:06
-
-
Save raeq/e39c4b1374e3ff1ddc82a408aafc33c3 to your computer and use it in GitHub Desktop.
Interleave two strings
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
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