SoccerGee
01-11-2012, 06:00 AM
I'm going through the Python Tutorial (http://docs.python.org/tutorial/controlflow.html) on the python website and needed a little extra explanation of what this code is actually doing. Maybe I'm just missing something obvious?
>>> for x in a[:]: # make a slice copy of the entire list
... if len(x) > 6: a.insert(0, x)
...
>>> a
['defenestrate', 'cat', 'window', 'defenestrate']
>>> for x in a[:]: # make a slice copy of the entire list
... if len(x) > 6: a.insert(0, x)
...
>>> a
['defenestrate', 'cat', 'window', 'defenestrate']