@@ -225,14 +225,14 @@ boundary::
225225 >>> def fib(n): # write Fibonacci series up to n
226226 ... """Print a Fibonacci series up to n."""
227227 ... a, b = 0, 1
228- ... while b < n:
229- ... print(b , end=' ')
228+ ... while a < n:
229+ ... print(a , end=' ')
230230 ... a, b = b, a+b
231231 ... print()
232232 ...
233233 >>> # Now call the function we just defined:
234234 ... fib(2000)
235- 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
235+ 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
236236
237237.. index ::
238238 single: documentation strings
@@ -276,7 +276,7 @@ mechanism::
276276 <function fib at 10042ed0>
277277 >>> f = fib
278278 >>> f(100)
279- 1 1 2 3 5 8 13 21 34 55 89
279+ 0 1 1 2 3 5 8 13 21 34 55 89
280280
281281Coming from other languages, you might object that ``fib `` is not a function but
282282a procedure since it doesn't return a value. In fact, even functions without a
@@ -296,22 +296,22 @@ Fibonacci series, instead of printing it::
296296 ... """Return a list containing the Fibonacci series up to n."""
297297 ... result = []
298298 ... a, b = 0, 1
299- ... while b < n:
300- ... result.append(b ) # see below
299+ ... while a < n:
300+ ... result.append(a ) # see below
301301 ... a, b = b, a+b
302302 ... return result
303303 ...
304304 >>> f100 = fib2(100) # call it
305305 >>> f100 # write the result
306- [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
306+ [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
307307
308308This example, as usual, demonstrates some new Python features:
309309
310310* The :keyword: `return ` statement returns with a value from a function.
311311 :keyword: `return ` without an expression argument returns ``None ``. Falling off
312312 the end of a function also returns ``None ``.
313313
314- * The statement ``result.append(b ) `` calls a *method * of the list object
314+ * The statement ``result.append(a ) `` calls a *method * of the list object
315315 ``result ``. A method is a function that 'belongs' to an object and is named
316316 ``obj.methodname ``, where ``obj `` is some object (this may be an expression),
317317 and ``methodname `` is the name of a method that is defined by the object's type.
@@ -320,7 +320,7 @@ This example, as usual, demonstrates some new Python features:
320320 object types and methods, using *classes *, see :ref: `tut-classes `)
321321 The method :meth: `append ` shown in the example is defined for list objects; it
322322 adds a new element at the end of the list. In this example it is equivalent to
323- ``result = result + [b ] ``, but more efficient.
323+ ``result = result + [a ] ``, but more efficient.
324324
325325
326326.. _tut-defining :
0 commit comments