forked from CodeMouse92/DeadSimplePython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecials_iteration.py
More file actions
25 lines (19 loc) · 829 Bytes
/
specials_iteration.py
File metadata and controls
25 lines (19 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
specials = ["pumpkin spice latte", "caramel macchiato", "mocha cappuccino"]
# first_iterator = specials.__iter__()
first_iterator = iter(specials)
# second_iterator = specials.__iter__()
second_iterator = iter(specials)
print(type(first_iterator)) # prints <class 'list_iterator'>
# item = first_iterator.__next__()
item = next(first_iterator)
print(item) # prints 'pumpkin spice latte'
# item = first_iterator.__next__()
item = next(first_iterator)
print(item) # prints 'caramel macchiato'
# item = second_iterator.__next__()
item = next(second_iterator)
print(item) # prints 'pumpkin spice latte'
# item = first_iterator.__next__()
item = next(first_iterator)
print(item) # prints 'mocha cappuccino'
item = next(first_iterator) # raises StopIteration