Skip to content

Instantly share code, notes, and snippets.

@nclv
Created January 17, 2020 20:09
Show Gist options
  • Save nclv/ad1227f748e2603950587d08c54225dc to your computer and use it in GitHub Desktop.
Save nclv/ad1227f748e2603950587d08c54225dc to your computer and use it in GitHub Desktop.
def iterate(iterable, n):
first = []
for second in iterable:
first.append(second)
if len(first) == n:
yield first
first.pop(0)
yield first
def main():
for element in iterate(["a", 45, None, 0, (4,5), [1]], 4):
print(element)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment