Skip to content

Commit 9d0b8ed

Browse files
committed
generators: Use range instead of xrange
xrange is 2.x only, range works in both
1 parent 848fabe commit 9d0b8ed

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

generators.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ which calculates fibonacci numbers:
8383
# generator version
8484
def fibon(n):
8585
a = b = 1
86-
for i in xrange(n):
86+
for i in range(n):
8787
yield a
8888
a, b = b, a + b
8989
@@ -102,7 +102,7 @@ However, if we would have implemented it like this:
102102
def fibon(n):
103103
a = b = 1
104104
result = []
105-
for i in xrange(n):
105+
for i in range(n):
106106
result.append(a)
107107
a, b = b, a + b
108108
return result
@@ -164,5 +164,5 @@ iterable. Here is how we can use it:
164164
Now that is much better. I am sure that you loved learning about
165165
generators. Do bear it in mind that you can fully grasp this concept
166166
only when you use it. Make sure that you follow this pattern and use
167-
``generators`` whenever they make sense to you. You wont be
167+
``generators`` whenever they make sense to you. You won't be
168168
disappointed!

0 commit comments

Comments
 (0)