Skip to content

Instantly share code, notes, and snippets.

@dawranliou
Created April 26, 2018 00:01
Show Gist options
  • Save dawranliou/480ab9b0ed70afcfc38ee1ed3025c44d to your computer and use it in GitHub Desktop.
Save dawranliou/480ab9b0ed70afcfc38ee1ed3025c44d to your computer and use it in GitHub Desktop.
def number_generator():
i = 0
while True:
yield i
i += 1
numbers = number_generator()
next(numbers) # 0
next(numbers) # 1
next(numbers) # 2
next(numbers) # 3
#...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment