Skip to content

Instantly share code, notes, and snippets.

@JackInTaiwan
Created October 20, 2019 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackInTaiwan/82596d86fde81005d3f3a4b9cecc21bb to your computer and use it in GitHub Desktop.
Save JackInTaiwan/82596d86fde81005d3f3a4b9cecc21bb to your computer and use it in GitHub Desktop.
python_iteration_6.py
x = (i for i in range(2))
print(type(x))
# <class 'generator'>
print(next(x))
print(next(x))
print(next(x))
# 0
# 1
# Traceback (most recent call last):
# File "/Users/jackcheng/Programming/python/notes/notes_11.py", line 125, in <module>
# print(next(x))
# StopIteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment