Skip to content

Instantly share code, notes, and snippets.

@norbertparti
Last active February 20, 2020 16:22
Show Gist options
  • Save norbertparti/7259ea4095086b5bf2140244082ad43a to your computer and use it in GitHub Desktop.
Save norbertparti/7259ea4095086b5bf2140244082ad43a to your computer and use it in GitHub Desktop.
#Merge even and odd numbers
even = (i for i in range(1,100) if i % 2 == 0)
odd = (i for i in range(1,100) if i % 2 != 0)
def imerge(a, b):
for i, j in zip(a,b):
yield i
yield j
print(list(imerge(even, odd)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment