[New-bugs-announce] [issue22202] Function Bug?
Reza Shahrzad
report at bugs.python.org
Fri Aug 15 02:15:09 CEST 2014
New submission from Reza Shahrzad:
Hi,
I hope this e-mail will get to the right person/department and looked at.
Thank you,
Reza Shahrzad
----------
files: List_Error.py, Uncertainty.docx
messages: 225326
nosy: rezashahrzad
priority: normal
severity: normal
status: open
title: Function Bug?
Added file: http://bugs.python.org/file36374/List_Error.py
Added file: http://bugs.python.org/file36375/Uncertainty.docx
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22202>
_______________________________________
-------------- next part --------------
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 "<pyshell#5>", line 1, in <module>
result
NameError: name 'result' is not defined
>>> result[3]
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
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 "<pyshell#12>", line 1, in <module>
results
NameError: name 'results' is not defined
>>> results[4]
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
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 "<pyshell#20>", line 1, in <module>
print(result)
NameError: name 'result' is not defined
>>> print(results)
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
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]
>>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Uncertainty.docx
Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Size: 37067 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/new-bugs-announce/attachments/20140815/54af9fc8/attachment-0001.docx>
More information about the New-bugs-announce
mailing list