Skip to content

Instantly share code, notes, and snippets.

@santiagobasulto
Created July 29, 2017 17:29
Show Gist options
  • Save santiagobasulto/33cb190163d1e717ffdff1c2f8b7f6ed to your computer and use it in GitHub Desktop.
Save santiagobasulto/33cb190163d1e717ffdff1c2f8b7f6ed to your computer and use it in GitHub Desktop.
def range(x, y=None):
if y is None:
y = x
x = 0
while x < y:
yield x # This is the generator
x += 1
# Tests ;)
generator = iter(range(10))
assert next(generator) == 0
assert next(generator) == 1
assert next(generator) == 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment