Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ============================================================== RESTART ============================================================== >>> >>> def fib(n): result = [] a, b = 0, 1 while a < n: result.append(a) a, b = b, a+b return result >>> fib(100) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] >>> >>> result Traceback (most recent call last): File "", line 1, in result NameError: name 'result' is not defined >>> result[3] Traceback (most recent call last): File "", line 1, in result[3] NameError: name 'result' is not defined >>> >>> >>> def fib(n): result = [] results = [] a, b = 0, 1 while a < n: result.append(a) results = result a, b = b, a+b return result >>> fib(100) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] >>> results Traceback (most recent call last): File "", line 1, in results NameError: name 'results' is not defined >>> results[4] Traceback (most recent call last): File "", line 1, in results[4] NameError: name 'results' is not defined >>> >>> >>> def fib(n): result = [] results = [] a, b = 0, 1 while a < n: result.append(a) results = result a, b = b, a+b print(result) print(results) return result >>> fib(100) [0] [0] [0, 1] [0, 1] [0, 1, 1] [0, 1, 1] [0, 1, 1, 2] [0, 1, 1, 2] [0, 1, 1, 2, 3] [0, 1, 1, 2, 3] [0, 1, 1, 2, 3, 5] [0, 1, 1, 2, 3, 5] [0, 1, 1, 2, 3, 5, 8] [0, 1, 1, 2, 3, 5, 8] [0, 1, 1, 2, 3, 5, 8, 13] [0, 1, 1, 2, 3, 5, 8, 13] [0, 1, 1, 2, 3, 5, 8, 13, 21] [0, 1, 1, 2, 3, 5, 8, 13, 21] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] >>> >>> print(result) Traceback (most recent call last): File "", line 1, in print(result) NameError: name 'result' is not defined >>> print(results) Traceback (most recent call last): File "", line 1, in print(results) NameError: name 'results' is not defined >>> >>> >>> z = [0, 1, 2, 3, 4, 5] >>> z [0, 1, 2, 3, 4, 5] >>> print(z) [0, 1, 2, 3, 4, 5] >>> z[3] 3 >>> z.append(6) >>> z [0, 1, 2, 3, 4, 5, 6] >>> y = z >>> y [0, 1, 2, 3, 4, 5, 6] >>> y[4] 4 >>> print(y) [0, 1, 2, 3, 4, 5, 6] >>>