Skip to content

Instantly share code, notes, and snippets.

@look4regev
Created December 6, 2017 08:58
Show Gist options
  • Save look4regev/8f5ba3dd0a4a9eb58fcca71078b79972 to your computer and use it in GitHub Desktop.
Save look4regev/8f5ba3dd0a4a9eb58fcca71078b79972 to your computer and use it in GitHub Desktop.
python list tools
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