[docs] docs@ InfiniteLoop in example on website
Abhinav Tyagi
abhityagi85 at gmail.com
Sun Apr 12 15:08:09 CEST 2015
Following example in Section 4.2 would run into infinite loop.
https://docs.python.org/2/tutorial/controlflow.html#for-statements
>>> for w in words[:]: # Loop over a slice copy of the entire list.... if len(w) > 6:... words.insert(0, w)...>>> words['defenestrate', 'cat', 'window', 'defenestrate']
Should be something like this (but still leaves duplicate elements in the
list):
-----------------------------------
words_tmp = copy.deepcopy(words)
for w in words_tmp:
if len(w)>6 :
words.insert(0,w)
-----------------------------------
Thanks & Regards
Abhinav Tyagi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20150412/e0ead62c/attachment.html>
More information about the docs
mailing list