Created
July 29, 2017 17:29
-
-
Save santiagobasulto/33cb190163d1e717ffdff1c2f8b7f6ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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