Created
December 14, 2016 00:40
-
-
Save vighneshbirodkar/ed406f43239d62c041c971f79aae56e0 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 iterator(value): | |
if value: | |
return 10 | |
else: | |
for i in range(5): | |
yield i | |
print(iterator(True), iterator(False)) | |
for x in iterator(True): | |
print(x) | |
for x in iterator(False): | |
print(x) | |
# Output | |
# <generator object iterator at 0x7f0571587eb8> <generator object iterator at 0x7f0571587f10> | |
# 0 | |
# 1 | |
# 2 | |
# 3 | |
# 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment