Skip to content

Commit eb397c5

Browse files
author
Sakis Kasampalis
committed
Merge pull request faif#6 from lihan/patch-1
Simplified the count_to function
2 parents e2d2609 + 1ccc5ed commit eb397c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

iterator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
def count_to(count):
55
"""Counts by word numbers, up to a maximum of five"""
66
numbers = ["one", "two", "three", "four", "five"]
7-
# The zip keeps from counting over the limit
8-
for number, pos in zip(numbers, list(range(count))):
7+
# enumerate() returns a tuple containing a count (from start which defaults to 0) and the values obtained from iterating over sequence
8+
for pos, number in enumerate(numbers):
99
yield number
1010

1111
# Test the generator

0 commit comments

Comments
 (0)