Skip to content

Commit 6876dd0

Browse files
committed
Simplify the code
1. remove useless comment 2. use slice syntax
1 parent 89e65c5 commit 6876dd0

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

behavioral/iterator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
def count_to(count):
1212
"""Counts by word numbers, up to a maximum of five"""
1313
numbers = ["one", "two", "three", "four", "five"]
14-
# enumerate() returns a tuple containing a count (from start which
15-
# defaults to 0) and the values obtained from iterating over sequence
16-
for pos, number in zip(range(count), numbers):
14+
for number in numbers[:count]:
1715
yield number
1816

1917
# Test the generator

0 commit comments

Comments
 (0)