| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,8 +4,8 @@ | |||
| 4 | 4 | def count_to(count): | |
| 5 | 5 | """Counts by word numbers, up to a maximum of five""" | |
| 6 | 6 | 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): | ||
| 9 | 9 | yield number | |
| 10 | 10 | ||
| 11 | 11 | # Test the generator | |
| Back | FazBrowse Home | New Git URL |
0 commit comments