Created
December 6, 2017 08:58
-
-
Save look4regev/8f5ba3dd0a4a9eb58fcca71078b79972 to your computer and use it in GitHub Desktop.
python list tools
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 interwine_element_into_list(lst, elem): | |
""" Usage example: ([1,2,3], 0) => [1,0,2,0,3,0] """ | |
res = [item for pair in zip(lst, [elem]*len(lst)) for item in pair] | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment