quick beginners List comprehension question

Steve Holden steve at holdenweb.com
Wed Jan 21 18:04:11 CET 2009


Lou Pecora wrote:
> In article <mailman.7691.1232554737.3487.python-list at python.org>,
>  Philip Semanchuk <philip at semanchuk.com> wrote:
> 
>> Other answers have been good; to them I'll add the comment that list  
>> comprehensions are for *constructing* lists, not manipulating the  
>> elements thereof.
>>
>> HTH
>> Philip
> 
> 
> Well this seems to work just fine.  What am I missing:
> 
>    A=[1,2,3]
>    print A
>    A=[2*a for a in A]
>    print A
> 
The fact that the lists to be multiplied are attributes of a list of
objects, and therefore aren't themselves a list. Look more closely at
the original poster's question.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list