Created
July 21, 2018 19:07
-
-
Save vinaykudari/7e2cf8d516abda9da73aa24e2eff8578 to your computer and use it in GitHub Desktop.
Generator Function
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 getrange(n): | |
```generator function``` | |
i = 0 | |
while i < n: | |
yield i | |
i += 1 | |
n = 3 | |
# calling generator function | |
a = getrange(n) # a is an iterator | |
next(a) | |
>> 0 | |
next(a) | |
>> 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment