[docs] docs@ InfiniteLoop in example on website
Abhinav Tyagi
abhityagi85 at gmail.com
Sun Apr 12 15:15:15 CEST 2015
Sorry for the inconvinience. I realised that the example is correct.
Thanks & Regards
Abhinav Tyagi
On 12 April 2015 at 18:38, Abhinav Tyagi <abhityagi85 at gmail.com> wrote:
> 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/e0042182/attachment.html>
More information about the docs
mailing list