summaryrefslogtreecommitdiffhomepage
path: root/python3.html.markdown
diff options
context:
space:
mode:
authorAcademia Pro Interlingua <AcProIL@mail.com>2019-11-01 13:42:54 +0100
committerGitHub <noreply@github.com>2019-11-01 13:42:54 +0100
commit92fe4d25790fb5f4df6c1363e28bbca7c76ada6e (patch)
tree5d99e53012e687f55707b0ce04ca6977498ebaa9 /python3.html.markdown
parent7c5841d5d5daba5cbe731f35da7787c29d209b41 (diff)
parenta4006483feb4c80cbac68856eadbc83c694f7050 (diff)
Merge pull request #1 from adambard/master
Update the fork
Diffstat (limited to 'python3.html.markdown')
-rw-r--r--python3.html.markdown10
1 files changed, 8 insertions, 2 deletions
diff --git a/python3.html.markdown b/python3.html.markdown
index 430927a9..61c53408 100644
--- a/python3.html.markdown
+++ b/python3.html.markdown
@@ -550,8 +550,14 @@ next(our_iterator) # => "three"
# After the iterator has returned all of its data, it raises a StopIteration exception
next(our_iterator) # Raises StopIteration
-# You can grab all the elements of an iterator by calling list() on it.
-list(filled_dict.keys()) # => Returns ["one", "two", "three"]
+# We can also loop over it, in fact, "for" does this implicitly!
+our_iterator = iter(our_iterable)
+for i in our_iterator:
+ print(i) # Prints one, two, three
+
+# You can grab all the elements of an iterable or iterator by calling list() on it.
+list(our_iterable) # => Returns ["one", "two", "three"]
+list(our_iterator) # => Returns [] because state is saved
####################################################