CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Python (http://www.codingforums.com/forumdisplay.php?f=46)
-   -   Tutorial Help (http://www.codingforums.com/showthread.php?t=248500)

SoccerGee 01-11-2012 06:00 AM

Tutorial Help
 
I'm going through the Python Tutorial on the python website and needed a little extra explanation of what this code is actually doing. Maybe I'm just missing something obvious?

Code:

>>> 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']


SoccerGee 01-11-2012 06:11 AM

Quote:

Originally Posted by SoccerGee (Post 1179643)
I'm going through the Python Tutorial on the python website and needed a little extra explanation of what this code is actually doing. Maybe I'm just missing something obvious?

Code:

>>> 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']


never mind... it's obviously past my bed time. :thumbsup:


All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.